#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ii = long long;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> v(n);
  vector<ii> s(n);
  for (int &x : v) {
    scanf("%d", &x);
  }
  for (int i = n - 2; i + 1; --i) {
    s[i] = v[i + 1] + s[i + 1];
  }
  s.pop_back();
  ii r = v[0] + (n > 1 ? s[0] : 0);
  sort(s.begin(), s.end(), greater<ii>());
  r += accumulate(s.begin(), s.begin() + k - 1, 0ll);
  printf("%lld\n", r);
}
