#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int N = 3e5 + 5;
inline int read() {
  int res = 0, ch, flag = 0;
  if ((ch = getchar()) == '-')
    flag = 1;
  else if (ch >= '0' && ch <= '9')
    res = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + ch - '0';
  return flag ? -res : res;
}
int t, n, m;
vector<int> data;
int k;
int main() {
  scanf("%d%d", &n, &k);
  int a, b;
  for (int i = 0; i < n; i++) {
    scanf("%d", &b);
    if (i) data.push_back(b - a);
    a = b;
  }
  sort(data.begin(), data.end());
  long long sum = 0;
  for (int i = 0; i < n - k; i++) sum += data[i];
  printf("%I64d\n", sum);
  return 0;
}
