#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
template <class T>
void read(T &x) {
  T f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9')
    if (s == '-') {
      f = -1;
      s = getchar();
    }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
long long n, a[maxn], b[maxn], k;
long long sum1, sum2;
int main() {
  read(n), read(k);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1; i <= n; i++) {
    b[i] = a[i + 1] - a[i];
  }
  sort(b + 1, b + n + 1, greater<long long>());
  for (int i = 1; i <= n - 1; i++) {
    if (i <= k - 1) sum1 += b[i];
    sum2 += b[i];
  }
  cout << sum2 - sum1 << endl;
  return 0;
}
