#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
#include <iomanip>
using namespace std;
using ll = long long;
void solve() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<vector<ll>> dp(n, vector<ll>(k + 1));
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			ll prev = 0;
			for (int c = i; c >= 0; c--) {
				ll nw = a[i] + (i - c) + 1;
				ll maxi = max(prev, nw);
				if (c == 0 && j == 1) {
					dp[i][j] = max(dp[i][j], maxi);
				}
				else if (c != 0) {
					dp[i][j] = max(dp[i][j], dp[c - 1][j - 1] + maxi);
				}
				prev = max(prev, nw) + 1;
			}
		}
	}
	cout << dp[n - 1][k];
}
int main()
{
	solve();
}

