#include <bits/stdc++.h>
using namespace std;
long long mx = INT_MAX;
long long mi = INT_MIN;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const long long sz = 1e6;
int main() {
  long long n, i, j, s = 0, p = 0, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (i = 0; i < n; i++) cin >> v[i];
  vector<long long> vv;
  for (i = 1; i < n; i++) vv.push_back(v[i] - v[i - 1]);
  if (k == n) {
    cout << 0;
    return 0;
  }
  sort(vv.rbegin(), vv.rend());
  for (i = k - 1; i < vv.size(); i++) {
    s = s + vv[i];
  }
  cout << s;
}
