#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
long long a[N], s[N];
bool cmp(long long a, long long b) { return a > b; }
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  s[n] = a[n];
  for (int i = n - 1; i >= 1; i--) s[i] = s[i + 1] + a[i];
  long long ans = s[1];
  sort(s + 2, s + n + 1, cmp);
  for (int i = 2; i <= k; i++) ans += s[i];
  cout << ans;
}
