#include <bits/stdc++.h>
using namespace std;
long long arr[300100];
long long suf[300100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  reverse(arr + 1, arr + n + 1);
  for (long long i = 1; i <= n; i++) {
    if (i == 1)
      suf[i] = arr[i];
    else
      suf[i] = arr[i] + suf[i - 1];
  }
  multiset<long long> m;
  for (long long i = 1; i <= n - 1; i++) {
    m.insert(suf[i]);
  }
  long long ans = suf[n];
  for (long long i = 1; i <= k - 1; i++) {
    ans += (*m.rbegin());
    m.erase(m.find(*m.rbegin()));
  }
  cout << ans << endl;
  return 0;
}
