#include <bits/stdc++.h>
#define arr3 array <int , 3>
#define pii pair <int , int>
#define fi first
#define se second
#define BIT(x , k) ((x >> k)&1)
#define MASK(x) (1ll << x)
#define int long long
using namespace std;
const int maxn = 1e6 + 4;
const int mod = 1e9 + 7;
const int INF = 1e18;
vector <int> a;
int n , k , t[maxn];
void solve()
{
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> t[i];
int ans = t[n] + 1 - t[1];
for(int i = 2; i <= n; i++)
{
a.push_back(t[i] - (t[i-1] + 1));
}
sort(a.begin() , a.end() , greater <int> ());
for(int i = 0; i < k-1; i++) ans -= a[i];
cout << ans << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
solve();
return 0;
}