#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long mpow(long long a, long long b, long long p = MOD) {
  a = a % p;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
const long long N = 1e5 + 3;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  k--;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = a[n - 1] - a[0];
  vector<long long> o;
  for (long long i = 1; i < n; i++) {
    o.push_back(-a[i] + a[i - 1]);
  }
  sort((o).begin(), (o).end());
  for (long long i = 0; i < k; i++) {
    ans += o[i];
  }
  cout << ans;
}
