#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> suff(n - 1);
  long long ans = 0, cur = 0;
  for (long long i = n - 1; i >= 0; i--) {
    cur += a[i];
    if (i == 0) {
      ans += cur;
    } else {
      suff[i - 1] = cur;
    }
  }
  sort(suff.begin(), suff.end());
  reverse(suff.begin(), suff.end());
  for (long long i = 0; i < k - 1; i++) {
    ans += suff[i];
  }
  cout << ans << endl;
}
