#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 23;
int a[maxn];
int n, k;
long long pre[maxn];
void init() {
  pre[0] = a[0];
  for (int i = 1; i < n; i++) pre[i] = (long long)pre[i - 1] + a[i];
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  long long ans = 0;
  init();
  ans = (long long)pre[n - 1] * k;
  sort(pre, pre + n - 1);
  for (int i = 0; i < k - 1; i++) ans = (long long)ans - pre[i];
  cout << ans;
}
