#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

template<typename T1,typename T2>
istream&operator>>(istream&in,pair<T1,T2>&a){
    return in>>a.first>>a.second;
}
template<typename T1,typename T2>
ostream&operator<<(ostream&out,const pair<T1,T2>&a){
    return out<<a.first<<' '<<a.second<<'\n';
}
template<typename T>
istream&operator>>(istream&in,vector<T>&a){
    for (auto &i:a)in>>i;
    return in;
}
template<typename T>
ostream&operator<<(ostream&out,const vector<T>&a){
    for (const auto &i:a)out<<i<<' ';
    return out;
}
template<typename T>
ostream&operator<<(ostream&out,const vector<vector<T>>&a){
    for (const auto &i:a)out<<i<<'\n';
    return out;
}
typedef long long ll;
struct solve{
    int n,k;
    vector<ll>a;
    multiset<ll>st;
    vector<vector<ll>>dp;
    const ll inf=1e15;
    solve(){
        cin>>n>>k;
        a.resize(n);
        cin>>a;
        vector<ll>ans(n-1);
        ll pref=-inf;
        for (int i=0;i<n-1;i++){
            pref=max(pref,a[i]+i+1);
            ans[i]=pref;
        }
        //cout<<ans<<'\n';
        pref=-inf;
        for (int i=n-2;i>=0;i--){
            pref=max(pref,a[i+1])+1;
            ans[i]+=pref;
        }
        ll res=-inf;
        for (auto i:ans)res=max(res,i);
        cout<<res<<'\n';
        //cout<<ans<<'\n';
    }
};
int main()
{
    int t=1;
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    while(t--)solve();
}
