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