#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){
int carry = 0;
rep(i, 0, m){
carry++;
if(carry > arr[i]) carry = arr[i];
ans = max(ans, carry);
}
for(int i = u; i>=0; i--){
carry++;
if(carry > arr[i]) carry = arr[i];
ans = max(ans, carry);
}
}
cout << ans;
}
// int carry = 0;
// rep(i, u, m){
// rep(w, u+1, m){
// carry++;
// if(carry > arr[i]) carry = arr[i];
// ans = max(ans, carry);
// }
// }
// carry = 0;
// for(int i = u; i>=0; i--){
// carry++;
// if(carry > arr[i]) carry = arr[i];
// ans = max(ans, carry);
// }
/*
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
*/