x,n,*p=list(map(int,open(0).read().split()))

print((min({*list(range(999))}-{*p},key=lambda y:abs(y-x))))
x,n,*p=list(map(int,open(i:=0).read().split()))

while x in p:x+=(-1)**i*i;i+=1

print(x)
x, n, *p = list(map(int, open(0).read().split()))
print((min({*list(range(999))} - {*p}, key=lambda y: abs(y - x))))

x, n, *p = list(map(int, open(i := 0).read().split()))
while x in p:
    x += (-1) ** i * i
    i += 1
print(x)

-x, n, *p = list(map(int, open(0).read().split())) -print((min({*list(range(999))} - {*p}, key=lambda y: abs(y - x)))) +x, n, *p = list(map(int, open(i := 0).read().split())) +while x in p: +    x += (-1) ** i * i +    i += 1 +print(x)