#include <bits/stdc++.h>
using namespace std;
bool marked[3 * 100000 + 10] = {0};
vector<long long int> a(3 * 100000 + 10);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k, ans;
  cin >> n >> k;
  vector<long long int> pref(n - 1);
  for (long long int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i > 0) {
      pref[i] = pref[i - 1] + a[i];
    } else if (i < n - 1) {
      pref[i] = a[i];
    }
  }
  ans = k * (pref[n - 2] + a[n - 1]);
  sort((pref).begin(), (pref).end());
  for (long long int i = 0; i < k - 1; ++i) {
    ans -= pref[i];
  }
  cout << ans << endl;
  return 0;
}
