#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")

using namespace std;
//using namespace __gnu_pbds;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

//typedef tree<int, null_type,less<int>,  rb_tree_tag, tree_order_statistics_node_update> ordered_set;

signed main(){
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#ifdef YA_KRUTOI
    freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin>>n>>k;
    vector<int> a(n);
    for(auto &x:a) cin>>x;
    vector<int> d(n);
    for(int i = 0; i < n; ++i){
        d[i] = a[i] + i + 1;
    }
    vector<int> pref(n), suf(n);
    pref[0] = d[0];
    suf[n-1] = d[n-1];
    for(int i = 1; i < n; ++i){
        pref[i] = max(pref[i-1], d[i]);
        suf[n-1-i] = max(suf[n-i], d[n-1-i]);
    }
    int ans = -1e18;
    for(int i = 0; i + 1 < n; ++i){
        ans = max(ans, pref[i] + suf[i+1] - i - 1);
    }
    cout<<ans<<'\n';
    return 0;
}
