program main
    implicit none
    integer x, n
    integer, allocatable, dimension(:) :: p
    integer, dimension(100) :: q
    integer i, min, d, a

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

    do i = 1, 100
        q(i) = i
    end do

    do i = 1, n
        q(p(i)) = 1000
    end do

    a = 1
    min = 200
    do i = 1, 100
        d = abs(q(i)-x)
        if(d < min) then
            min = d
            a = q(i)
        else if (d == min) then
            if (q(i) < a) then
                a = q(i)
            end if
        end if
    end do
    
    write(*,*) a

end program
