#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
long long a[N], sum[N];
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sum[n] = a[n];
  for (int i = n - 1; i >= 1; i--) {
    sum[i] = sum[i + 1] + a[i];
  }
  sort(sum + 2, sum + n + 1, greater<long long>());
  long long ans = 0;
  for (int i = 1; i <= k; i++) ans += sum[i];
  cout << ans << endl;
  return 0;
}
