#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> pref(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        pref[i] = max(pref[i - 1], a[i - 1] + i);
    }
    vector<int> suff(n + 1, 0);
    for (int i = n - 1; i >= 0; i--) {
        suff[i] = max(suff[i + 1] + 1, a[i] + 1);
    }
    
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans = max(ans, pref[i] + suff[i]);
    }

    cout << ans << '\n';
}