#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
ll t[100005] = { 0 };
int main() {
	ll n, k;
	cin >> n >> k;
	rep(i, n) cin >> t[i];
	ll sum = 0;
	vector<ll>v;
	for (int i = 1; i < n; i++) {
		sum += t[i] - (t[i - 1] + 1);
		v.pb(t[i] - (t[i - 1] + 1));
	}
	VSORT(v);
	reverse(all(v));
	rep(i, k - 1) {
		sum -= v[i];
	}
	out(n + sum);
	return 0;
}
