#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
  return out << "(" << a.first << ", " << a.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    if (v[i] != 1e18 + 1)
      os << v[i];
    else
      os << "INF";
    if (i != v.size() - 1) os << ", ";
  }
  os << "]\n";
  return os;
}
int main() {
  {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  };
  int n, k;
  cin >> n >> k;
  vector<long long int> v(n), pref(n);
  long long int sum1 = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum1 += v[i];
  }
  pref[n - 1] = v[n - 1];
  pref[0] = -1e18 + 1;
  for (int i = n - 2; i >= 1; i--) {
    pref[i] = pref[i + 1] + v[i];
  }
  sort(pref.begin() + 1, pref.end());
  reverse(pref.begin() + 1, pref.end());
  long long int count = 0;
  for (int i = 1; i <= k - 1; i++) {
    count += pref[i];
  }
  cout << count + sum1 << endl;
  return 0;
}
