program abc13
 implicit none
 integer,allocatable::a(:)
 integer::X,N,ia,b=0,ib=1,ic,c,d,s=0,id,ie=0
 read(*,*)X,N
 allocate(a(N))
 read(*,*)(a(ia),ia=1,N)
 do id=1,N
  if(X==a(id))then
   ie=1
  end if
 end do
 if(ie==0)then
  print'(i0)',X
  stop
 end if
 do while(b==0)
  c=0
  d=0
  do ic=1,N
   if(X+ib==a(ic))then
    c=1
   end if
   if(X-ib==a(ic))then
    d=1
   end if
  end do
  if(d==0)then
   s=X-ib
  else if(c==0)then
   s=X+ib
  end if
  if(c==0.or.d==0)then
   b=1
  end if
  ib=ib+1
 end do
 print'(i0)',s
end program abc13