#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (auto &x : v) cin >> x;
  reverse(v.begin(), v.end());
  vector<long long> sum(n, 0ll);
  for (long long i = 0; i < n; ++i) {
    sum[i] += v[i];
    if (i > 0) sum[i] += sum[i - 1];
  }
  long long ans = sum[n - 1];
  sum.pop_back();
  sort(sum.rbegin(), sum.rend());
  for (long long i = 0; i + 1 < k; ++i) {
    ans += sum[i];
  }
  cout << ans << "\n";
  return 0;
}
