program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: cnt(0:101), x,n,i,l,r
    integer(int32), allocatable:: p(:)

    read*, x,n
    allocate(p(n))
    read*, p(:)
    cnt(:) = 0
    do i=1,n
        cnt(p(i))=cnt(p(i))+1
    end do

    l=x
    r=x

    do while(0 /= l .or. r /= 101)
        if (cnt(l) == 0) then
            print'(i0)', l 
            stop
        end if

        if (cnt(r) == 0) then
            print'(i0)', r
            stop
        end if

        l=max(l-1,0)
        r=min(r+1,101)
    end do
end program main