#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, a[maxn];
long long ans, sum[maxn];
bool cmp(long long A, long long B) { return A > B; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + a[i];
  sort(sum + 2, sum + 1 + n, cmp);
  for (int i = 2; i <= m; i++) ans += sum[i];
  printf("%lld\n", ans + sum[1]);
  return 0;
}
