x,n=list(map(int,input().split()))

p=list(map(int, input().split()))

youso=[]

for i in range(-300,1000):

    if not i in p:

        youso+=[i]

hikaku=[]

for i in youso:

    hikaku+=[(i,abs(x-i))]

hikaku1=sorted(hikaku,key=lambda x:x[1])

res=hikaku1[0][0]

print(res)
x,n=list(map(int,input().split()))

p=list(map(int, input().split()))

if not x in p:print(x)

else:

    for i in range(500):

        if not x-i in p:

            print((x-i))

            break

        elif not x+i in p:

            print((x+i))

            break
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
youso = []
for i in range(-300, 1000):
    if not i in p:
        youso += [i]
hikaku = []
for i in youso:
    hikaku += [(i, abs(x - i))]
hikaku1 = sorted(hikaku, key=lambda x: x[1])
res = hikaku1[0][0]
print(res)

x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
if not x in p:
    print(x)
else:
    for i in range(500):
        if not x - i in p:
            print((x - i))
            break
        elif not x + i in p:
            print((x + i))
            break

-youso = [] -for i in range(-300, 1000): -    if not i in p: -        youso += [i] -hikaku = [] -for i in youso: -    hikaku += [(i, abs(x - i))] -hikaku1 = sorted(hikaku, key=lambda x: x[1]) -res = hikaku1[0][0] -print(res) +if not x in p: +    print(x) +else: +    for i in range(500): +        if not x - i in p: +            print((x - i)) +            break +        elif not x + i in p: +            print((x + i)) +            break