#include <bits/stdc++.h>
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
int n, k;
int a[N];
int c[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 2; i <= n; ++i) c[i - 1] = a[i] - a[i - 1];
  sort(c + 1, c + n);
  int ans = 0;
  for (int i = 1; i < n - k + 1; ++i) ans += c[i];
  cout << ans << endl;
  return 0;
}
