#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, k, i, j, x;
  cin >> n >> k;
  vector<long long> v, d;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  d.push_back(0);
  for (i = 1; i < n; i++) {
    x = v[i] - v[i - 1];
    d.push_back(x);
  }
  sort(d.rbegin(), d.rend());
  long long s = 0;
  for (i = k - 1; i < n; i++) {
    s = s + d[i];
  }
  cout << s;
  exit(0);
}
