#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
bool iscut[N];
long long qs[N];
struct A {
  long long idx, val;
  bool operator<(const A& o) const { return val > o.val; }
};
priority_queue<A> q;
int main() {
  long long n, k, last, ans = 0;
  scanf("%lld %lld", &n, &k);
  iscut[0] = 1;
  last = n;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &qs[i]), qs[i] += qs[i - 1];
    if (i != n) q.push({i, qs[i]});
  }
  for (long long i = 1; i < k; i++) iscut[q.top().idx] = 1, q.pop();
  for (long long i = n; i >= 0; i--) {
    if (iscut[i]) ans += (qs[last] - qs[i]) * k, --k, last = i;
  }
  printf("%lld\n", ans);
  return 0;
}
