program ABC170_C
  integer(8)::X,N,cnta=0,cntb=0
  integer(8),allocatable::P(:)
  read(*,*)X,N
  if(N==0) then
     write(*,*)X
     stop
  end if
  allocate(P(N))
  read(*,*)P
  do i=0,100
     do j=1,N
        if(X-i==P(j)) then
           cnta=0
        else
           cnta=cnta+1
           if(cnta==N) then
              write(*,*)X-i
              stop
           end if
        end if
        if(X+i==P(j)) then
           cntb=0
        else
           cntb=cntb+1
           if(cntb==N) then
              write(*,*)X+i
              stop
           end if
        end if
        if(j==N) then
           cnta=0
           cntb=0
        end if
     end do
    end do
end program ABC170_C