#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const double eps = 1e-10;
const long long linf = 1e18 + 7;
const long long hh = 523;
int a[300007];
long long suf[300007];
int main() {
  int n, k;
  long long ans = 0;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  suf[n] = a[n];
  for (int i = n - 1; i >= 1; i--) {
    suf[i] = suf[i + 1] + a[i];
  }
  ans = suf[1];
  sort(suf + 2, suf + n + 1);
  for (int i = n; i >= n - k + 2; i--) {
    ans += suf[i];
  }
  printf("%I64d\n", ans);
  return 0;
}
