#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (auto &i : a) cin >> i;
  vector<long long> suf(n);
  suf[n - 1] = a[n - 1];
  for (int i = n - 2; i > -1; i--) suf[i] = suf[i + 1] + a[i];
  long long ans = suf[0];
  suf.erase(suf.begin());
  sort(suf.begin(), suf.end());
  reverse(suf.begin(), suf.end());
  for (int i = 0; i < k - 1; i++) ans += suf[i];
  cout << ans << endl;
}
int main() {
  cout.precision(30);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  solve();
  return 0;
}
