#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 10;
const long long M = 998244353;
const long double PI = acos(-1);
long long n, k;
long long a[N], s[N];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long i;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = n; i >= 1; i--) s[i] = s[i + 1] + a[i];
  long long sum = s[1];
  sort(s + 2, s + n + 1, greater<long long>());
  for (i = 2; i <= k; i++) sum += s[i];
  cout << sum;
  return 0;
}
