#include <bits/stdc++.h>
using namespace std;
int n, k, ans, a[300005], c[300005];
inline int read() {
  int red = 0, f_f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f_f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') red = red * 10 + ch - '0', ch = getchar();
  return red * f_f;
}
bool cmp(int x, int y) { return x > y; }
int main() {
  n = read(), k = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (i != 1) c[i - 1] = a[i] - a[i - 1];
  }
  ans = a[n] - a[1];
  sort(c + 1, c + n, cmp);
  for (int i = 1; i < k; i++) {
    ans -= c[i];
  }
  printf("%d\n", ans);
  return 0;
}
