#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vo vector
#define pb push_back
#define sz(x) x.size()
#define fi first
#define se second
typedef long long ll;
typedef pair<int ,int> pii;
typedef vo<int> vi;
#define rep(i, a, b) for(ll i=(a); i<(b); i++)
#define pr(x) cout << #x << " " << x << endl;
ll const inf = LLONG_MAX, mxn = 1e5+4;
int n, m, ans;
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
vi arr(m);
rep(i, 0, m){
cin>>arr[i];
}
if(n==1){
rep(u, 0, m){
rep(i, u+1, m){
int carry = 0;
rep(w, u, i){
carry++;
if(carry > arr[w]) carry = arr[w];
ans = max(ans, carry);
}
for(int w = i-1; w>=u; w--){
carry++;
if(carry > arr[w]) carry = arr[w];
ans = max(ans, carry);
}
}
rep(i, 0, u){
int carry = 0;
for(int w = u; w>=i, w--){
carry++;
if(carry > arr[w]) carry = arr[i];
ans = max(ans, carry);
}
rep(w, i, u){
carry++;
if(carry > arr[w]) carry = arr[w];
ans = max(ans, carry);
}
}
}
}
cout << ans;
}
/*
precalc if each square can go home with a specific amt of coins
calc if we can get there with dfs from that square too
*/