#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
vector < int > a(n);
for(int &i : a)cin >> i;
vector < array < int , 3 > > v;
for(int i = 1; i < n; i++)
v.push_back({abs(a[i] - a[i - 1]), i - 1, i});
sort(v.rbegin(), v.rend());
map < pair < int , int > , bool > vis;
for(int i = k - 1; i < n - 1; i++){
vis[{v[i][1], v[i][2]}] = true;
}
// for(auto [x, y] : vis){
// auto [x1, x2] = x;
// cout << x1 << '-' << x2 << ' ' << y << endl;
// }
int tot = 0;
for(int i = 0; i < n; i++){
if(vis[{i, i + 1}] == false){
tot++;
continue;
}
int j = i;
while(j < n - 1 && vis[{j, j + 1}] == true)
j++;
tot += a[j] - a[i] + 1;
i = j;
}
cout << tot << endl;
}