#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> data(N);
  for (int i = 0; i < N; i++) cin >> data[i];
  vector<int> diffs(N - 1);
  for (int i = 1; i < N; i++) diffs[i - 1] = data[i] - data[i - 1];
  sort(diffs.begin(), diffs.end());
  int res = 0;
  for (int i = N - K - 1; i >= 0; i--) {
    res += diffs[i];
  }
  cout << res << endl;
  return 0;
}
