#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  vector<pair<long long, long long>> v;
  for (long long i = 0; i < n - 1; i++) {
    v.push_back(make_pair(arr[i + 1] - arr[i], i));
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  long long lol = 0;
  reverse(v.begin(), v.end());
  for (long long i = k - 1; i < n - 1; i++) {
    ans += v[i].first;
  }
  cout << ans;
  return 0;
}
