#include <bits/stdc++.h>
using namespace std;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = ml * kk + 7;
const long long inf = ml * ml * ml + 7;
long long n, i, j, k;
vector<long long> m;
bool viv = false;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    long long a;
    cin >> a;
    m.push_back(a);
  }
  long long ans = 0;
  long long ubr = n - k;
  for (long long i = 0; i < n; i++) ans += m[i] * (i + 1);
  vector<long long> tos;
  reverse(m.begin(), m.end());
  long long cur = 0;
  for (long long i = 0; i < n - 1; i++) {
    cur += m[i];
    tos.push_back(cur);
  }
  sort(tos.begin(), tos.end());
  for (long long i = 0; i < ubr; i++) ans -= tos[i];
  cout << ans << endl;
  return 0;
}
