#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 3;
long long n, k, a[maxn], part[maxn], res;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 1; i--) {
    if (i == n - 1) {
      part[i - 1] = a[i];
      continue;
    }
    part[i - 1] = part[i] + a[i];
  }
  res = part[0] + a[0];
  sort(part, part + n - 1, greater<long long>());
  for (int i = 0; i < k - 1; i++) res += part[i];
  cout << res;
}
