#include <bits/stdc++.h>
using namespace std;
const long long INF = 4e18;
const int MAX = 5e5 + 5;
const long long mod = 998244353;
long long n, k, a[MAX], pref[MAX], ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i], ans += a[i];
  pref[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i) pref[i] = pref[i + 1] + a[i];
  sort(pref + 1, pref + n);
  for (int i = n - 1; i >= n - (k - 1); --i) ans += pref[i];
  cout << ans << '\n';
  return 0;
}
