#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];
	}
	ll all = 0;
	for (int i = 0; i < 3; i++) {
		ll c1 = 0;
		for (int j = 0; j <= i; j++) {
			c1 = max(c1, a[j] + (j - 0) + 1);
		}
		ll c2 = 0;
		for (int j = i + 1; j < n; j++) {
			c2 = max(c2, a[j] + (j - (i + 1)) + 1);
		}
		all = max(all, c1 + c2);
	}
	cout << all;
}
int main()
{
	solve();
}

