#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int n, m,j[110000],ans;
	vector<int> s;
	cin >> n >> m;
	ans = n;
	cin >> j[0];
	REPO(i, n - 1) {
		cin >> j[i];
		s.push_back(j[i] - j[i - 1]);
	}
	sort(ALL(s));
	REP(i, n - m) {
		ans += s[i] - 1;
	}
	cout << ans << endl;
}


