local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end

X=io.read"*n"
N=io.read"*n"
if(N==0)then print(X)return end

A=reada(N)
table.sort(A)

for i=1,N do
	if(A[i]>=X)then a=i break end
end
if(A[a]~=X)then print(X)return end
i=0
while(true)do
	if(A[a-i]~=X-i)then print(X-i)return end
	if(A[a+i]~=X+i)then print(X+i)return end
	i=i+1
end
