#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 3e5 + 10;
long long sum[N];
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> v;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &sum[i]);
  }
  for (int i = n; i >= 1; i--) sum[i] += sum[i + 1];
  sort(sum + 2, sum + n + 1);
  reverse(sum + 2, sum + n + 1);
  long long ans = 0;
  for (int i = 1; i <= k; i++) ans += sum[i];
  printf("%lld\n", ans);
  return 0;
}
