program main
	implicit none
	integer(8):: N,i,j,t,K,X
	integer,dimension(1:100)::A,B,C
	read *, X,N
    read(*,*) (A(i), i = 1, N)
	t=0
	k=0
	do j=1,N
	do i=1,N
		if((A(i)-X+t)==0)then
			t=t+1
			exit
		end if
	end do
	do i=1,N
		if((A(i)-X-k)==0)then
			k=k+1
			exit
		end if
	end do
	end do

	if(t==0.and.k==0)		print'(I0)',X
	
	if (t>k)t=k
	
	do i=1,N
	
		if((A(i)-X+t)/=0)then
		print'(I0)',X-t
		stop
		end if
		if((A(i)-X-t)/=0)then
		print'(I0)',X+t
		stop
		end if
	end do
end program main