   program abc170c
      implicit none
      integer::x,n
      integer,allocatable,dimension(:)::p
      logical,allocatable,dimension(:)::check
      integer::i,step


         read *, x,n
         allocate( p(n),check(-100:200) )
         check=.false.
         read *, p(1:n)

         if ( n==0 ) then
            print *, x
            stop
         end if

         do i=1,n
            check(p(i))=.true.
         end do

         if ( check(x) .eqv. .false. ) then
            print *, x
            stop
         end if

         step=0
         do while ( check(x+step) .and. check(x-step) )
            step=step+1
            if ( check(x+step) .eqv. .false. ) then
               if ( check(x-step) .eqv. .false. ) then
                  print *, x-step
                  stop
               else
                  print *, x+step
                  stop
               end if
            else if ( check(x-step) .eqv. .false. ) then
               print *, x-step
               stop
            end if
         end do


   end program abc170c