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