#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];
    priority_queue<ll, vector<ll>, greater<ll> > ma;
    for(int i = 1; i < n; i++) ma.push(t[i] - t[i - 1] - 1);
    ll ans = n, kx = n;
    while(kx > k){
        kx--;
        ans += ma.top();
        ma.pop();
    }
    cout << ans << endl;
    return 0;
}
