program answer
  implicit none

  integer :: x, n, i, j, m
  integer, allocatable :: p(:)
  integer :: ans(101)

  read(*,*) x, n
  allocate(p(n))
  read(*,*) p

  if(N==0) then
     write(*,*) x
     stop
  end if

  if(N==100) then
     if(x<=50) then
        write(*,*) 0
        stop
     else
        write(*,*) 101
        stop
     end if
  end if

  do i = 1, 101
     do j = 1, N
        if(i == p(j)) then
           ans(i) = 1000
        end if
     end do
  end do

  do i = 1, 101
  if(ans(i)/=1000) then
     ans(i) = abs(x-i)
  end if
  end do

  m = minval(ans)

  do i = 1, 101
     if(ans(i)==m) then
        write(*,*) i
        exit
     end if
  end do

  deallocate(p)

  stop
 end program answer
     
