#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,K; cin >> N >> K; vector A(K); for(auto &a : A) cin >> a; for(int i=0; i 1){ int mid = (high+low)/2; int now = 0,pos = i; while(now < K){ int apos = upper_bound(A.begin(),A.end(),pos)-A.begin(); int next = max(A.at(apos)+1,pos+mid*2); if(next > i+2*N) break; now++; pos = next; } if(now == K) low = mid; else high = mid; } answer = max(answer,low*2); } cout << answer << endl; }