#include<bits/stdc++.h>usingnamespacestd;longlongsolve(vector<longlong>&a){intn=a.size();vector<longlong>prefix_max_when_source_is_to_the_right(n);vector<longlong>suffix_max_when_source_is_to_the_left(n);longlongcurrent_max=-1;for(inti=0;i<n;i++){// In the worst case, all elements to the right would be deleted first
// Hence, x - right_count >= a[i]
// x >= a[i] + right_count
longlongcurrent_cost=a[i]+(n-1)-i;prefix_max_when_source_is_to_the_right[i]=max(current_cost,current_max);current_max=max(current_max,current_cost);}current_max=-1;for(inti=n-1;i>=0;i--){// In the worst case, all elements to the left would be deleted first
// Hence, x - left_count >= a[i]
// x >= a[i] + left_count
longlongcurrent_cost=a[i]+i;suffix_max_when_source_is_to_the_left[i]=max(current_cost,current_max);current_max=max(current_max,current_cost);}vector<longlong>source(n,0);// source[i] is the answer when the source is the (i-th) element.
for(inti=0;i<n;i++){source[i]=a[i];if(i-1>=0){source[i]=max(source[i],prefix_max_when_source_is_to_the_right[i-1]);}if(i+1<n){source[i]=max(source[i],suffix_max_when_source_is_to_the_left[i+1]);}}return*min_element(source.begin(),source.end());}intmain(){intn;cin>>n;vector<longlong>a(n);for(inti=0;i<n;i++){cin>>a[i];}autores=solve(a);cout<<res<<endl;return0;}