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