#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 10;
const long long INF = 2e18;
const long double DINF = 1.79769e+308;
long long n, k, a[MAXN], ans;
multiset<long long, greater<long long>> st;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += a[i];
    if (i != 0) {
      st.insert(sum);
    }
  }
  ans += sum;
  long long cnt = 0;
  for (auto it = st.begin(); it != st.end(); it++) {
    if (cnt == k - 1) {
      break;
    }
    ans += (*it);
    cnt++;
  }
  cout << ans;
  return 0;
}
