#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
long long n, k, pre[3000005], a[3000005], ans;
signed main() {
  n = read();
  k = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = n; i >= 1; i--) pre[i] = pre[i + 1] + a[i];
  sort(pre + 2, pre + n + 1);
  for (long long i = n; i >= n - k + 2; i--) ans += pre[i];
  ans += pre[1];
  cout << ans << endl;
}
