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



int main(){
    int x,y,i,n,a;
    cin>>x>>n;
    map<int,int>mp;
    for(i=0;i<n;i++){
        cin>>a;
        mp[a]++;
    }
    i=x;
    while(mp[i]==1){
        i--;
    }
    y=x;
    while(mp[y]==1)y++;
    if(abs(x-i)<=abs(x-y))cout<<i;
    else cout<<y;
}
