#include <bits/stdc++.h>
using namespace std;
const int ms = 5e5 + 10;
long long p[ms];
int n, m;
long long res;
int main() {
  int a, b;
  scanf("%d%d", &n, &m);
  p[0] = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a);
    p[i] = p[i - 1] + a;
  }
  res += m * p[n];
  sort(p + 1, p + n);
  for (int i = 1; i < m; ++i) {
    res -= p[i];
  }
  printf("%lld\n", res);
  return 0;
}
