#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define ll long long

vector<ll> pref;
vector<ll> suf;

ll f1(ll ind) {
    if (ind < 0 || ind >= pref.size()) {
        return -1e18;
    }
    return pref[ind];
}

ll f2(ll ind) {
    if (ind < 0 || ind >= suf.size()) {
        return -1e18;
    }
    return suf[ind];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    pref.resize(n);
    suf.resize(n);
    pref[0] = a[0] + 1;
    for (ll i = 1; i < n; i++) {
        pref[i] = max(pref[i - 1], a[i] + i + 1);
    }
    suf[n - 1] = a[n - 1] + n;
    for (ll i = n - 2; i >= 0; i--) {
        suf[i] = max(suf[i + 1], a[i] + i + 1);
    }
    ll answer = 0;
    for (ll i = 0; i < n; i++) {
        ll answer1 = a[i] + 1;
        answer1 += max(answer1, max(f1(i - 1), f2(i + 1) - 1));
        answer = max(answer, answer1);
    }
    cout << answer;
}