#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using T = pair<ll, int>;
const int N = (int)3e5 + 50;
int n, k;
int a[N];
ll s[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  s[n] = 0;
  for (int i = n - 1; i >= 0; i--) s[i] = s[i + 1] + a[i];
  k--;
  nth_element(s + 1, s + 1 + k, s + n, greater<ll>());
  cout << accumulate(s, s + 1 + k, 0ll);
  return 0;
}
