program sample
    implicit none
    integer(8) ::a, b,c,i,j,m,n,k,a1,b1,c1
    integer(8)::x,y(100)
    integer(8),allocatable::p(:)
    read(*,*) x,n
    if (n==0)then
        write(*,*)x
        stop
    end if
    allocate(p(n))

    read(*,*)p
    do i=1,100
        y(i)=1
    end do
    do i=1,n
        y(p(i))=0
    end do
    do i=0,100
        if (x-i==0)then
            write(*,*)x-i
            stop
        end if
        if ( x+i==101)then
            write(*,*)x+i
            stop
        end if 
        if (y(x-i)==1) then
            write(*,*)x-i
            stop
        end if
        if (y(x+i)==1) then
            write(*,*)x+i
            stop
        end if
    end do
    stop
    
    
end program sample
  

