#include <bits/stdc++.h>
using namespace std;
int in() {
  int ret;
  cin >> ret;
  return ret;
}
const int N = 3e5 + 10, INF = 1e9 + 7;
int n, k = 1, m;
long long a[N], sum[N], ans;
pair<long long, int> p[N];
bool mark[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sum[n] = a[n], p[n] = {sum[n], n};
  for (int i = (n - 1); i > 1; i--)
    sum[i] = sum[i + 1] + a[i], p[i] = {sum[i], i};
  sort(p + 2, p + n + 1);
  for (int i = n; i > (n - m + 1); i--) mark[p[i].second] = true;
  for (int i = 1; i <= n; i++) {
    if (mark[i]) k++;
    ans += a[i] * k;
  }
  cout << ans << '\n';
  return 0;
}
