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

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



i=0



while True:

    if not x-i in a:

        print((x-i))

        break

    if not x+i in a:

        print((x+i))

        break

    i+=1
import sys



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

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

p.sort()



if n==0:

    print(x)

    sys.exit()



if x not in p:

    print(x)

    sys.exit()

    

q=list(i for i in range(p[0]-1,p[-1]+2))



for i in p:

    q.remove(i)



ans=[]

c=x+n

for i in q:

    if c>abs(x-i):

        c=abs(x-i)

        ans.clear()

        ans.append(i)

    if c==abs(x-i):

        ans.append(i)



print((min(ans)))
x, n = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 0
while True:
    if not x - i in a:
        print((x - i))
        break
    if not x + i in a:
        print((x + i))
        break
    i += 1

import sys

x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
if n == 0:
    print(x)
    sys.exit()
if x not in p:
    print(x)
    sys.exit()
q = list(i for i in range(p[0] - 1, p[-1] + 2))
for i in p:
    q.remove(i)
ans = []
c = x + n
for i in q:
    if c > abs(x - i):
        c = abs(x - i)
        ans.clear()
        ans.append(i)
    if c == abs(x - i):
        ans.append(i)
print((min(ans)))

+import sys + -a = list(map(int, input().split())) -i = 0 -while True: -    if not x - i in a: -        print((x - i)) -        break -    if not x + i in a: -        print((x + i)) -        break -    i += 1 +p = list(map(int, input().split())) +p.sort() +if n == 0: +    print(x) +    sys.exit() +if x not in p: +    print(x) +    sys.exit() +q = list(i for i in range(p[0] - 1, p[-1] + 2)) +for i in p: +    q.remove(i) +ans = [] +c = x + n +for i in q: +    if c > abs(x - i): +        c = abs(x - i) +        ans.clear() +        ans.append(i) +    if c == abs(x - i): +        ans.append(i) +print((min(ans)))