#include <bits/stdc++.h>
using namespace std;
const int N = 300000 + 1067;
long long a[N];
int res;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = n; i >= 1; i--) a[i] = a[i + 1] + a[i];
  long long res = a[1];
  sort(a + 2, a + n + 1);
  for (int i = n; i >= n - k + 2; i--) res += a[i];
  cout << res << endl;
  return 0;
}
