#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
mt19937 rng(time(0));
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n), b;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long cur = 0;
  for (int i = n - 1; i >= 1; i--) {
    cur += a[i];
    b.push_back(cur);
  }
  cur += a[0];
  long long ans = cur;
  sort(b.rbegin(), b.rend());
  for (int i = 0; i < k - 1; i++) {
    ans += b[i];
  }
  cout << ans;
}
