#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int arr[n + 2];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long int sum[n + 2];
  for (int i = n; i >= 1; i--) {
    if (i == n)
      sum[i] = arr[i];
    else
      sum[i] = sum[i + 1] + arr[i];
  }
  long long int co = 0;
  sort(sum + 2, sum + n + 1);
  for (int i = n, c = 1; c < k; i--, c++) {
    co += sum[i];
  }
  cout << co + sum[1] << endl;
}
int main() {
  std::ios::sync_with_stdio(false);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
