#include <bits/stdc++.h>
// #ifndef ONLINE_JUDGE
// #include "algo/debug.h"
// #endif
using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const int sz = 2e5 + 5, inf = 1e18, mod = 1e9 + 7;
int a[sz];
void _(){
int n, k;
cin >> n >> k;
vector<int> d;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i > 1) d.push_back(a[i] - a[i - 1]);
}
sort(all(d));
if (n == k) {
cout << k << endl;
return;
}
if (k == 1) {
cout << a[n] << endl;
return;
}
int ans = k, c = n - k;
for (auto x : d) {
if (c > 0) {
ans += x;
c--;
} else break;
}
cout << ans << endl;
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(0);
int T = 1;
// cin >> T;
while (T--) _();
}