#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 1;
int n, k, a[maxn];
int id[maxn], c[maxn];
long long s[maxn];
void Input() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
void Solve() {
  s[n] = a[n];
  id[n] = n;
  for (int i = n - 1; i >= 1; i--) {
    s[i] = s[i + 1] + (long long)a[i];
    id[i] = i;
  }
  sort(id + 2, id + 1 + n, [](int x, int y) { return s[x] > s[y]; });
  fill(c + 1, c + 1 + n, 0);
  for (int i = 1; i <= k; i++) c[id[i]] = 1;
  int j = k;
  long long res = 0, pre = 0;
  for (int i = n; i >= 1; i--)
    if (c[i] == 1) {
      res += (s[i] - pre) * (long long)j;
      j--;
      pre = s[i];
    }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Input();
  Solve();
}
