#include <stdio.h>
#include <algorithm>
using namespace std;

int dif[111111];

int main(void)
{
	int n, k, i, ans = 0;

	scanf("%d %d" ,&n, &k);
	if (n <= k)
	{
		printf("%d\n" ,n);
		return 0;
	}

	int prev, now;
	for (i = 1; i <= n; i++)
	{
		prev = now;
		scanf("%d" ,&now);

		dif[i - 1] = now - prev - 1;
	}

	sort(dif + 1, dif + n);
	for (i = 1; i <= n - k; i++)
		ans += dif[i];

	printf("%d\n" ,ans + n);
	return 0;
}
