#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 5;
long long a[maxn], ps[maxn], mark[maxn];
set<pair<long long, long long> > st;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  ps[n] = a[n];
  st.insert(pair<long long, long long>(ps[n], n));
  for (long long i = n - 1; i >= 1; i--) {
    ps[i] = ps[i + 1] + a[i];
    if (i == 1) continue;
    st.insert(pair<long long, long long>(ps[i], i));
  }
  for (long long i = 1; i < k; i++) {
    pair<long long, long long> p = *st.rbegin();
    mark[p.second]++;
    st.erase(p);
  }
  long long c = 1, ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (mark[i]) {
      c++;
    }
    ans += c * a[i];
  }
  cout << ans << endl;
  return 0;
}
