#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long int n, k;
    cin >> n >> k;
    long long int arr[n + 1];
    for (long long int i = 1; i <= n; i++) cin >> arr[i];
    long long int prefix[n + 1];
    prefix[n + 1] = 0;
    for (long long int i = n; i >= 1; i--) {
      prefix[i] = prefix[i + 1] + arr[i];
    }
    vector<long long int> v;
    for (long long int i = 2; i <= n; i++) v.push_back(prefix[i]);
    sort((v).begin(), (v).end());
    long long int ans = prefix[1];
    for (long long int i = n - 2; i >= n - k; i--) ans += v[i];
    cout << ans;
  }
  return 0;
}
