#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using namespace std;
const int MX = 300 * 1000 + 7;
ll a[MX];
ll s[MX];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    s[i] = s[i + 1] + a[i];
  }
  ll ans = s[0];
  vector<ll> go;
  for (int i = 1; i < n; i++) {
    go.push_back(s[i]);
  }
  sort(go.rbegin(), go.rend());
  for (int i = 0; i < k - 1; i++) {
    ans += go[i];
  }
  cout << ans << "\n";
  return 0;
}
