#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n, k, t[100010];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> t[i];
    
    vector<int> interval;
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        if (t[i + 1] > t[i] + 1) {
            interval.push_back(t[i + 1] - t[i] - 1);
            sum += t[i + 1] - t[i] - 1;
        }
    }
    
    int ans = t[n - 1] - t[0] + 1 - sum;
    sort(interval.begin(), interval.end());
    
    if (interval.size() >= k)
    for (int i = 0; i <= interval.size() - k; i++) {
        ans += interval[i];
    }
    
    cout << ans << endl;
    
}

