#include <bits/stdc++.h>
const int MAXN = 300100;
int a[MAXN], b[MAXN];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 1; i < n; ++i) b[i] = a[i] - a[i - 1];
  std::sort(b + 1, b + n);
  int cnt = 0;
  for (int i = 1; i < k; ++i) cnt += b[n - i];
  printf("%d\n", a[n - 1] - a[0] - cnt);
  return 0;
}
