#include <bits/stdc++.h>
using namespace std;
long long a[300005], b[300005];
bool cmp(long long aa, long long bb) { return aa > bb; }
void solve() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  b[n] = 0;
  for (int i = n - 1; i >= 0; i--) b[i] = b[i + 1] + a[i];
  sort(b + 1, b + n, cmp);
  long long ans = 0;
  for (int i = 0; i < k; i++) ans += b[i];
  printf("%lld\n", ans);
}
int main() {
  solve();
  return 0;
}
