#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int k;
  cin >> k;
  int arr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int a[n - 1];
  for (int i = 0; i < n - 1; i++) {
    a[i] = arr[i + 1] - arr[i];
  }
  sort(a, a + n - 1);
  int s = 0;
  for (int i = n - k; i < n - 1; i++) s += a[i];
  s += arr[0] - arr[n - 1];
  cout << -1 * s;
  return 0;
}
