#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n);
  vector<long long> suffix(n);
  for (long long i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  suffix[n - 1] = arr[n - 1];
  for (long long i = n - 2; i >= 0; --i) {
    suffix[i] = arr[i] + suffix[i + 1];
  }
  long long res = suffix[0];
  suffix.erase(suffix.begin());
  sort(suffix.begin(), suffix.end());
  k--;
  for (long long i = n - 2; i >= 0 && k--; --i) {
    res += suffix[i];
  }
  cout << res;
}
