#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
const int INF = 0x3f3f3f3f;
const int iinf = 1 << 30;
const long long linf = 2e18;
const int MOD = 1000000007;
const double eps = 1e-7;
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
template <class T>
void print(T a) {
  cout << a << endl;
  exit(0);
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void upd(T &a, T b) {
  a = (1ll * a + b) % MOD;
}
template <class T>
void mul(T &a, T b) {
  a = (long long)a * b % MOD;
}
int n, k;
long long a[N];
signed 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 - 1); i++) a[n] -= a[i];
  printf("%lld\n", a[n]);
  return 0;
}
