#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int a[maxn], b[maxn];
int main(int argc, char *argv[]) {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i == 0)
      b[i] = 0;
    else
      b[i] = a[i] - a[i - 1];
  }
  sort(b, b + n);
  int cot = 0;
  for (int i = 0; i < n - k + 1; i++) {
    cot += b[i];
  }
  printf("%d\n", cot);
}
