#include <bits/stdc++.h>
using namespace std;
int ans, n, k, a[300005], b[300005];
int main() {
  int i;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i < n; i++) b[i] = a[i + 1] - a[i];
  sort(b + 1, b + n);
  ans = 0;
  for (i = 1; i <= n - k; i++) ans += b[i];
  printf("%d", ans);
  return 0;
}
