#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	vector<long long>v;
	long long a; cin >> a;
	for (int i = 1; i < n; i++) {
		long long b; cin >> b;
		v.push_back(b - a - 1);
		a = b;
	}
	sort(v.begin(), v.end());
	int ans = n;
	for (int i = 0; i < n - k; i++)ans += v[i];
	cout << ans << endl;
	return 0;
}
