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

print((min({*list(range(999))}-{*p},key=lambda y:(abs(y-x),y))))
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(0).read().split()))
print((min({*list(range(999))} - {*p}, key=lambda y: (abs(y - x), y))))

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

-print((min({*list(range(999))} - {*p}, key=lambda y: (abs(y - x), y)))) +print((min({*list(range(999))} - {*p}, key=lambda y: abs(y - x))))