#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000005;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int n, k;
long long a[maxn];
priority_queue<long long> q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  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];
    if (i != 1) q.push(a[i]);
  }
  long long ans = a[1];
  for (int i = 1; i <= k - 1; i++) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}
