#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
int n, k;
long long a[MAXN];
bool cmp(long long a, long long b) { return a > b; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int ii = 1; ii <= n; ii++) cin >> a[ii];
  for (int ii = n - 1; ii >= 1; ii--) {
    a[ii] += a[ii + 1];
  }
  sort(a + 2, a + n + 1, cmp);
  for (int ii = 2; ii <= k; ii++) {
    a[1] += a[ii];
  }
  cout << a[1] << "\n";
}
