#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  int b[n - 1];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    b[i] = a[i + 1] - a[i];
  }
  long long int sum = 0;
  sort(b, b + (n - 1));
  for (int i = 0; i < n - k; ++i) {
    sum += b[i];
  }
  cout << sum << endl;
  return 0;
}
