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