#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << showpoint;
  cout << setprecision(11);
  int n, k;
  cin >> n >> k;
  long long int sm = 0;
  long long int ar[n];
  for (auto ii = 0; ii != n; ii++) {
    cin >> ar[ii];
    sm += ar[ii];
  }
  long long int su[n];
  memset(su, 0, sizeof(su));
  su[n - 1] = LLONG_MAX;
  su[0] = ar[0];
  for (int i = 1; i < n - 1; i++) {
    su[i] = su[i - 1];
    su[i] += ar[i];
  }
  sort(su, su + n);
  long long int ans = k * sm;
  sm = 0;
  for (int i = 0; i < k - 1; i++) {
    sm += su[i];
  }
  cout << ans - sm;
  return 0;
}
