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