#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long a[N], sfx[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i > 0; i--) sfx[i] = sfx[i + 1] + a[i];
  vector<long long> v;
  for (int i = 2; i <= n; i++) v.push_back(sfx[i]);
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  long long ans = sfx[1];
  for (int i = 0; i < k - 1; i++) ans += v[i];
  cout << ans << endl;
  return 0;
}
