#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  long long int val, i;
  vector<long long int> v;
  for (i = 0; i < n; i++) {
    cin >> val;
    v.push_back(val);
  }
  long long int suffix_array[n];
  suffix_array[n - 1] = v[n - 1];
  for (i = n - 2; i >= 0; i--) suffix_array[i] = suffix_array[i + 1] + v[i];
  std::vector<long long int> temp;
  for (i = 1; i < n; i++) temp.push_back(suffix_array[i]);
  sort(temp.begin(), temp.end());
  reverse(temp.begin(), temp.end());
  long long int ans = suffix_array[0];
  k--;
  for (auto uj : temp) {
    if (k == 0) break;
    ans += uj;
    k--;
  }
  cout << ans << endl;
}
