#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  long long a[300000], sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (long long i = n - 2; i >= 0; i--) {
    a[i] += a[i + 1];
  }
  sort(a + 1, a + n, greater<long long>());
  for (long long i = 1; i < k; i++) {
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}
