#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &X) {
  X = 0;
  char ch = 0;
  T op = 1;
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') op = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    X = (X << 3) + (X << 1) + ch - 48;
  X *= op;
}
const int INF = 0x3f3f3f3f;
const int N = 3e5 + 5;
long long a[N];
long long n, k;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  long long ans = a[n] * k;
  sort(a + 1, a + n);
  for (int i = 1; i <= k - 1; i++) ans -= a[i];
  cout << ans;
  return 0;
}
