#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long N = 3e5 + 5;
const long long mod = 1000000007;
long long n, k;
long long a[N];
long long pref[N];
void testCase() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  vector<long long> sums;
  for (long long i = n; i >= 1; i--) {
    sum += a[i];
    pref[i] = sum;
    if (i != 1) {
      sums.push_back(pref[i]);
    }
  }
  long long ans = sum;
  sort(sums.begin(), sums.end());
  reverse(sums.begin(), sums.end());
  for (long long i = 0; i < k - 1; i++) {
    ans += sums[i];
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) testCase();
  return 0;
}
