#ifdef LOCAL
#include ".debug.hpp"
#else
#define debug(...) 42
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
signed main() {
#ifndef VOID
cin.tie(nullptr)->sync_with_stdio(false);
#endif
const int64_t INF = 1e18;
int N, K; cin >> N >> K;
vector<int64_t> A(N + 1); for (int i = 1; i <= N; i++) cin >> A[i];
vector<vector<int64_t>> dp(N + 1, vector<int64_t> (K + 1, INF));
for (int i = 1; i <= K; i++) dp[1][i] = 1;
for (int i = 2; i <= N; i++) {
for (int j = 1; j <= K; j++) {
dp[i][j] = min(dp[i - 1][j] + A[i] - A[i - 1], dp[i - 1][j - 1] + 1);
}
}
int64_t MIN = INF;
for (int i = 1; i <= K; i++) MIN = min(MIN, dp[N][i]);
cout << MIN << '\n';
return 0;
}