program main
	implicit none
	integer(8):: N,i,j,t,K,X
	integer,dimension(1:2*100000)::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((X+t)-A(i)==0)then
			t=t+1
			exit
			end if
		end do
		do i=1,N
			if((X-k)-A(i)==0)then
			k=k+1
			exit
			end if
		end do
	end do
	
	if(t==0.and.k==0)then
		print'(I0)',X
		stop
	end if
	
	if(t==k)then
		print'(I0)',X-k
		stop
	end if
	if(t>k)then
		print'(I0)',X-k
		stop
	else	
		print'(I0)',X+t
		stop
	end if
end program main