#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 10, NM = 1 << 16, MOD = 1e9 + 7, INF = 1e15 + 10,
                SQ = 640, LOG = 20;
long long n, m, x1, x2, z, x, y, y2, t, maxi, ans, dp[N], a[N], mini, ptr, k, q,
    pos, posi, l, r;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i) {
      a[i] += a[i - 1];
    }
  }
  ans = k * a[n - 1];
  sort(a, a + n - 1);
  for (int i = 0; i < k - 1; i++) {
    ans -= a[i];
  }
  cout << ans;
}
