#include <bits/stdc++.h>
using namespace std;
long long a[300010], b[300010];
int n, k;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  b[1] = a[n];
  for (int i = 2; i <= n; i++) {
    b[i] = b[i - 1] + a[n - i + 1];
  }
  sort(b + 1, b + n);
  reverse(b + 1, b + n);
  long long ans = b[n];
  for (int i = 1; i < k; i++) ans += b[i];
  cout << ans;
  return 0;
}
