#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define LL long long
using namespace std;
int N, K;
LL T[100010];
LL ans;
priority_queue<LL> pq;
int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> T[i];
		if(i > 0) pq.push(T[i] - T[i - 1] - 1);
	}
	ans = T[N - 1] - T[0] + 1;
	for(int i = 0; i < K - 1; i++){
		ans -= pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}
