#include <bits/stdc++.h>
using namespace std;
long long a, b, ans, p;
long long c[300009];
int main() {
  cin >> a >> b;
  for (long long i = 0; i < a; i++) cin >> c[i];
  for (long long i = a - 1; i >= 0; i--) p += c[i], c[i] = p;
  ans = p;
  sort(c + 1, c + a);
  for (long long i = a - 1; i > a - b; i--) ans += c[i];
  cout << ans;
}
