#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<tuple>
#include<cassert>
#define int long long
using namespace std;
int test[213456], aa[213456];
signed main() {
	int n, m, sum = 0; cin >> n >> m;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	for (int h = 1; h < n; h++) {
		aa[h] = test[h] - test[h - 1] - 1;
	}
	sort(aa + 1, aa + n);
	for (int h = 1; h <= n - m; h++) {
		sum += aa[h];
	}
	cout << n + sum << endl;
}
