#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<int> a(n + 2);
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[0] = a[1];
  a[n + 1] = a[n];
  vector<int> b(n + 2);
  vector<pair<int, int>> cnt(n + 1);
  b[0] = b[n + 1] = 1;
  for (int i = 0; i <= n; i++) cnt[i] = {a[i + 1] - a[i], i};
  sort(cnt.begin(), cnt.end());
  reverse(cnt.begin(), cnt.end());
  for (int i = 0; i < k - 1; i++) {
    b[cnt[i].second] = 1;
  }
  long long ans = 0;
  int i = 0, j = 0;
  while (j < k) {
    int t = i + 1;
    int d = t;
    while (b[d] == 0) d++;
    ans = ans + a[d] - a[t];
    j++;
    i = d;
  }
  cout << ans;
}
