#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  k--;
  vector<long long> suf(n);
  suf[n - 1] = d[n - 1];
  for (int i = n - 2; i >= 0; i--) suf[i] = suf[i + 1] + d[i];
  long long sum = suf[0];
  vector<long long> g;
  for (int i = 1; i < n; i++) g.push_back(suf[i]);
  sort(g.begin(), g.end());
  reverse(g.begin(), g.end());
  for (int i = 0; i < k; i++) sum += g[i];
  cout << sum << endl;
}
int main() {
  solve();
  return 0;
}
