X, N = list(map(int, input().split()))

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



min_ = 0

while True:

    front = X - min_

    back = X + min_

    if front in P and back in P:

        min_ += 1

    else:

        break



front = X - min_

back = X + min_

if front not in P:

    print(front)

else:

    print(back)
X, N = list(map(int, input().split()))

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



min_ = 100

for i in range(0, 102):

    cur = i 

    if cur in P:

        continue

    diff = abs(X - cur)

    if diff < min_:

        min_ = diff



front = X - min_

back = X + min_

if front not in P:

    print(front)

else:

    print(back)
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
min_ = 0
while True:
    front = X - min_
    back = X + min_
    if front in P and back in P:
        min_ += 1
    else:
        break
front = X - min_
back = X + min_
if front not in P:
    print(front)
else:
    print(back)

X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
min_ = 100
for i in range(0, 102):
    cur = i
    if cur in P:
        continue
    diff = abs(X - cur)
    if diff < min_:
        min_ = diff
front = X - min_
back = X + min_
if front not in P:
    print(front)
else:
    print(back)

-min_ = 0 -while True: -    front = X - min_ -    back = X + min_ -    if front in P and back in P: -        min_ += 1 -    else: -        break +min_ = 100 +for i in range(0, 102): +    cur = i +    if cur in P: +        continue +    diff = abs(X - cur) +    if diff < min_: +        min_ = diff