#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300001;
int a[MAXN];
long long s[MAXN], ans;
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
  }
  ans = s[n] * k;
  if (k > 1) {
    sort(s + 1, s + n);
    for (int i = 1; i < k; i++) ans -= s[i];
  }
  cout << ans << endl;
  return 0;
}
