#include <bits/stdc++.h>
#define hash _hash_
#define y1 _y1_
#define left _left_
#define right _right_
#define dec _dec_
#define int long long
using namespace std;
using ll = long long;
using ull = unsigned long long;
/*----------- I alone decide my fate! ------------*/
/*  I just do what I gotta, in the heat of the summer...  */
int N, K, a[100009], d[100009];
void solve() {
	cin >> N >> K;
	for (int i = 1; i <= N; i ++) {
		cin >> a[i];
	}
	for (int i = 2; i <= N; i ++) {
		d[i - 1] = a[i] - a[i - 1] - 1;
	}
	sort(d + 1, d + N, greater <int> ());
	ll res = a[N] - a[1] + 1;
	for (int i = 1; i < K; i ++) {
		res -= d[i];
	}
	cout << res;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    solve();
}
/*
  How can you see into my eyes, like open doors?
  Leading you down into my core, where I've become so numb
  Without a soul, my spirit's sleeping somewhere cold
  Until you find it here and bring it back home!
  Wake me up! Wake me up inside
  Cant wake up? Wake me up inside
*/
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |