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

int main(){
	int x,i,n,l,r,ans;
  cin>>x>>n;
  vector<int> a(n);
  map<int,int> b;
  for(i=0;i<n;++i){
    cin>>a[i];
    b[a[i]]=1;
  }
  l=r=x;
  while(b[l]) l--;
  while(b[r]) r++;
  cout<<(abs(l-x)<=abs(r-x)?l:r);
}
