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