#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
long long n, k, m, ans;
long long a[N], b[N];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = n; i; i--) b[i] = b[i + 1] + a[i];
  sort(b + 2, b + n + 1);
  for (int i = n; i > n - k + 1; i--) ans += b[i];
  cout << ans + b[1];
}
