#include<iostream>
#include<set>
using namespace std;
int main()
{
  int x,n,i,p,q;
  cin>>x>>n;
  set<int> S;
  for(i=0;i<n;i++)
  {
    cin>>p;
  	S.insert(p);
  }
  p=x;
  while(S.count(p))
    --p;
  q=x;
  while(S.count(q))
    ++q;
  if(x-p<=q-x)
    cout<<p;
  else
    cout<<q;
}