#include<bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;
const int N = (int)1e4 + 5;
const int inf = (int)2e9 + 5;
const int mod = 998244353;
void solve() {
int N, K;
cin >> N >> K;
vector<ll> T(N);
for (int i = 0; i < N; i++) cin >> T[i];
vector<ll> gap;
for (int i = 0; i < N - 1; i++) {
gap.push_back(T[i+1] - T[i] - 1);
}
sort(gap.begin(), gap.end());
ll ans = N;
int need = max(0ll, N - K);
for (int i = 0; i < need; i++) {
ans += gap[i];
}
cout << ans << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
for(int i = 1; i <= t; i++) {
// cout << "Case " << i << ": ";
solve();
}
}