#include <bits/stdc++.h>
using namespace std;
struct node {
  long long val, id;
} a[300005];
bool cmp(node x, node y) { return x.val < y.val; }
int main() {
  ios::sync_with_stdio(0);
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i].val;
    a[i].val += a[i - 1].val;
    a[i].id = i;
  }
  long long res = a[n].val * k;
  sort(a + 1, a + n + 1, cmp);
  long long flag = 0;
  for (long long i = 1; i - flag <= k - 1; ++i) {
    if (a[i].id == n) {
      flag = 1;
      continue;
    }
    res -= a[i].val;
  }
  cout << res << endl;
  return 0;
}
