#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define fi first
#define se second
#define pb push_back
#define endl '\n'
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
template<class T> using is = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>void show(vector<T> &v){
for(auto &i: v){
cout << i << ' ';
}
cout << endl;
}
const int N = 1e4+5, INF = 1e10, LOG = 18, MOD = 998244353;
void solve(){
int n,k;
cin >> n >> k;
vector<pair<int,int>> a(n+1);
for(int i = 1; i <= n; i++){
cin >> a[i].fi;
a[i].se = i;
}
vector<pair<int,int>> v;
sort(a.begin(), a.end());
for(int i = 2; i <= n; i++){
v.pb({a[i].fi+1 - a[i-1].fi,a[i].se});
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
vector<bool> cut(n+1);
for(int i = 0; i < k-1; i++){
cut[v[i].se] = 1;
}
int ans = 0, s = a[1].fi;
for(int i = 2; i <= n; i++){
if(cut[a[i].se]){
ans += a[i-1].fi+1-s;
s = a[i].fi;
}
}
ans += a[n].fi+1 - s;
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
for(int i = 1; i <= t; i++){
//cout << "Scenario #" << i << ": " << endl;
solve();
}
}