program forbidden_list
  implicit none
  integer :: x, n, p(100) = 0, i, d = 1e9, m = -1e9
  logical :: u(-2:102) = .false.
  read(*,*) x, n
  if (n == 0) then
    write(*,'(i0)') x
    stop
  end if
  read(*,*) p(1:n)
  do i = 1, n
    u(p(i)) = .true.
  end do
  do i = -2, 102
    if (u(i)) cycle
    if (d > abs(i-x)) then
      d = abs(i-x)
      m = i
    end if
  end do
  write(*,'(i0)') m
end program forbidden_list