import sys

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

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

min_dif = 10000

output = 10000

for i in range(10000):

  if (5000 - i in p) == False:

    if abs(X-(5000-i)) <= min_dif:

      min_dif = abs(X-(5000 - i))

      output =  5000 - i

print(output)

      

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

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

p.sort()

diff = 100000

ans = 0

for i in range(-200, 200):

  if i not in p:

    if abs(X-i) < diff:

      diff = abs(X-i)

      ans = i

print(ans)
import sys

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
min_dif = 10000
output = 10000
for i in range(10000):
    if (5000 - i in p) == False:
        if abs(X - (5000 - i)) <= min_dif:
            min_dif = abs(X - (5000 - i))
            output = 5000 - i
print(output)

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
diff = 100000
ans = 0
for i in range(-200, 200):
    if i not in p:
        if abs(X - i) < diff:
            diff = abs(X - i)
            ans = i
print(ans)

-import sys - -min_dif = 10000 -output = 10000 -for i in range(10000): -    if (5000 - i in p) == False: -        if abs(X - (5000 - i)) <= min_dif: -            min_dif = abs(X - (5000 - i)) -            output = 5000 - i -print(output) +p.sort() +diff = 100000 +ans = 0 +for i in range(-200, 200): +    if i not in p: +        if abs(X - i) < diff: +            diff = abs(X - i) +            ans = i +print(ans)