      PROGRAM forbiddenList
      IMPLICIT NONE
      INTEGER,PARAMETER :: prec = 16
      integer(prec) :: x,n,ans,ansi,tempAns
      integer(prec), allocatable :: p(:)
      integer(prec) :: i, j
      
      read*,x,n
      allocate( p(n) )
      read*,p
      
      ans = 100000
      ansI = 10000
      
      outer:&
      do i = -200,300
        do j = 1,n
          if( i==p(j) )then
            cycle outer
          end if
        end do
        
        tempAns = abs( i-x )
        
        if( tempAns<=ans )then
          if( tempAns==ans )then
            if( i>ansI )then
              cycle outer
            end if
          end if
          
          ans = tempAns
          ansI = i
          
        end if
        
      end do outer
      
      print*,ansI
      
      
      
      stop
      !debugg
      
      print*,ans
      
      
      END PROGRAM