#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long a[maxn];
int n, k;
int main() {
  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];
  sort(a + 2, a + n + 1);
  reverse(a + 2, a + 1 + n);
  long long ans = 0;
  for (int i = 1; i <= k; ++i) ans += a[i];
  cout << ans << endl;
  return 0;
}
