#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  vector<long long> v;
  long long num, sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (i != n - 1) v.push_back(sum + num);
    sum += num;
  }
  long long ans = sum * k;
  sum = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < k - 1; i++) sum += v[i];
  ans = ans - sum;
  cout << ans << endl;
  return 0;
}
