#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  int cd[n - 1];
  int arr[n], seg = n - k, beg = 1, en = 1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cd[i] = arr[i + 1] - arr[i];
  }
  sort(cd, cd + n - 1, greater<int>());
  for (int i = 0; i < k - 1; i++) {
    ans += cd[i];
  }
  ans = arr[n - 1] - arr[0] - ans;
  cout << ans << "\n";
}
