#include <bits/stdc++.h>
using namespace std;
int n, k;
long long a[300001];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]), a[i] += a[i - 1];
  a[n] *= k;
  sort(a + 1, a + n);
  for (int i = 1; i < k; ++i) a[n] -= a[i];
  printf("%lld", a[n]);
}
