#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> t(n);
    for(int i=0; i<n; i++){
        cin >> t[i];
    }
    vector<int> diff(n-1);
    for(int i=0; i<n-1; i++){
        diff[i] = t[i+1] -t[i] -1;
    }
    sort(diff.begin(), diff.end(), greater<int>());
    int ans = t[n-1]+1 -t[0];
    for(int i=0; i<m-1; i++){
        ans -= diff[i];
    }
    cout << ans << endl;
    return 0;
}

