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