#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<long long> a(n), suff(n + 1);
  for (int i = 0; i <= n - 1; i++) cin >> a[i];
  suff[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    suff[i] = suff[i + 1] + a[i];
  }
  long long ans = 0;
  sort(suff.begin() + 1, suff.end() - 1, greater<long long>());
  for (int i = 0; i < k; i++) {
    ans += suff[i];
  }
  cout << ans;
  return 0;
}
