#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define endl '\n'
const int inf = 1e9+7;
const int N = 2e5+5;
inline void test_case() {
int n, k;
cin >> n >> k;
vector<int> t(n);
for (int i = 0; i < n; i++) {
cin >> t[i];
}
vector<int> a;
for (int i = 1; i < n; i++) {
a.pb(t[i] - t[i-1]);
}
sort(a.rbegin(), a.rend());
int ans = t[n-1]-t[0];
for (int i = 0; i < k-1 && i < (int)a.size(); i++) {
ans -= a[i];
}
ans += k;
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while (T--) test_case();
}