#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
struct grtr {
  template <class T>
  bool operator()(T const &a, T const &b) {
    return (a > b);
  }
};
int n, k, t;
long long s = 0;
vector<long long> a, b;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    a.push_back(t);
  }
  for (int i = n - 1; i > 0; i--) {
    s += a[i];
    b.push_back(s);
  }
  s += a[0];
  sort(b.begin(), b.end(), grtr());
  for (int i = 0; i < k - 1; i++) {
    s += b[i];
  }
  cout << s;
}
