#include <bits/stdc++.h>
#define int int64_t
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;



signed main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);


    for (int &i : a)
        cin >> i;
    
    vector<int> pref(n), suf(n);

    pref[0] = a[0] + 1;
    suf[n - 1] = a[n - 1] + n;

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

    for (int i = n - 2; i >= 0; i--)
        suf[i] = max(suf[i], a[i] + i + 1);


    int res = 0;

    for (int i = 0; i + 1 < n; i++) {
        res = max(res, pref[i] + suf[i + 1] - i - 1);
    }

    cout << res;
}