//#pragma GCC target("avx, avx2")
#pragma GCC optimize("O3, Ofast, unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <random>
#include <vector>
#include <map>


using namespace std;
using ll = long long;

#define all(a) a.begin(), a.end()
#define each(x, a) for(auto &x : a)



void solve() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	each(x, a) {
		cin >> x;
	}
	ll t = n - k + 1;
	ll ans = 0;
	for (int i = t - 1; i < n; ++i) {
		ll cur = a[i] + t;
		for (int j = i + 1; j < n; ++j) {
			cur += a[j] + 1;
		}
		vector<ll> d;
		for (int j = 0; j < i; ++j) {
			d.push_back(a[j]);
		}
		sort(all(d));
		for (int j = t - 1 ; j < d.size(); ++j) {
			cur += d[j] + 1;
		}
		ans = max(ans, cur);
	}
	cout << ans;
}


signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll t = 1;
	// cin >> t;
	while (t--) {
		solve();
		cout << '\n';
	}
}