#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0, iLen = (n); i < iLen; ++i) cin >> a[i];
  vector<ll> delta;
  for (int i = 1, iLen = (n); i < iLen; ++i)
    delta.emplace_back(a[i] - a[i - 1]);
  sort(delta.begin(), delta.end());
  ll ans = 0;
  for (int i = 0, iLen = (n - k); i < iLen; ++i) ans += delta[i];
  cout << ans << endl;
}
