#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define yes "Yes"
#define no "No"
#define pp pop_back
#define int long long
using namespace std;
void solve() {
int n,k;
cin>>n>>k;
vector<int>t(n);
for (int i=0;i<n;i++){
cin>>t[i];
}
int ans=n;
vector<int> gaps;
for (int i = 1; i < n; i++) {
gaps.push_back(t[i] - t[i-1] - 1);
}
sort(all(gaps));
for (int i = 0; i < n - k; i++) {
ans += gaps[i];
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--) {
solve();
}
return 0;
}