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

#define int long long
int const N=2e5+5;
int const mod=1e9+7;

void solve(){
	int n,k;
	cin>>n>>k;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
		arr[i]+=(i+1);
	}
	int ans=0;
	int mx=arr[n-1];
	for(int i=n-2;i>=0;i--){
		ans=max(ans,(arr[i]+mx)-(i+1));
		// cout<<(arr[i]+mx)-(i+1)<<endl;
		mx=max(arr[i],mx);
	}
	cout<<ans<<endl;
}

signed main(){
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}