#include <bits/stdc++.h>
using namespace std;
int ara[300005];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", ara + i);
  long long ans = 0;
  vector<long long> vec;
  for (int i = n; i; i--) {
    ans += ara[i];
    if (i > 1) vec.push_back(ans);
  }
  sort(vec.begin(), vec.end(), greater<long long>());
  for (int i = 0; i < k - 1; i++) ans += vec[i];
  printf("%lld\n", ans);
  return 0;
}
