#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long INF = 1e9 + 7;
long long n, k, Q, a[N], b[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long res = 0;
  for (long long i = n; i >= 1; i--) b[i] = b[i + 1] + a[i];
  sort(b + 2, b + n + 1);
  reverse(b + 2, b + n + 1);
  for (long long i = 1; i <= k; i++) res += b[i];
  cout << res << endl;
  return 0;
}
