#include <bits/stdc++.h>
using namespace std;
const long long maxN = 3e5 + 100;
long long n, k, s[maxN + 1];
long long ans;
inline long long read() {
  long long num = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
  return num * f;
}
int main() {
  n = read(), k = read();
  for (long long i = 1; i <= n; i++) s[i] = read();
  for (long long i = n; i >= 1; i--) s[i] += s[i + 1];
  ans = s[1];
  sort(s + 2, s + n + 1);
  for (long long i = n; i >= max(2LL, n - k + 2); i--) ans += s[i];
  printf("%I64d", ans);
  return 0;
}
