#include <bits/stdc++.h>
using namespace std;
int num[333333];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int x = k - 1;
  priority_queue<long long, vector<long long>, greater<long long> > pq;
  int now = 0;
  long long sumnow = 0;
  for (int i = 1; i < n + 1; i++) scanf("%d", &num[i]);
  for (int i = n; i > 1; i--) {
    sumnow += num[i];
    if (pq.size() < x)
      pq.push(sumnow);
    else if (!pq.empty() && pq.top() < sumnow)
      pq.pop(), pq.push(sumnow);
  }
  long long res = sumnow + num[1];
  while (!pq.empty()) res += pq.top(), pq.pop();
  printf("%I64d\n", res);
}
