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

ans=[]

if M==0:

  print(N)

  exit()

c=N

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

while True:

  if c not in L:

    ans.append(c)

    break

  else:

    c+=1

c=N

while True:

  if c not in L:

    ans.append(c)

    break

  else:

    c-=1

if abs(ans[0]-N)>=abs(ans[1]-N):

  print((ans[1]))

elif abs(ans[0]-N)<abs(ans[1]-N):

  print((ans[0]))

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

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

if N not in L:

  print(N)

  exit()

c=N

d=N

while True:

  if c not in L:

    break

  else:

    c-=1

while True:

  if d not in L:

    break

  else:

    d+=1

if abs(d-N)>=abs(c-N):

  print(c)

else:

  print(d)
N, M = list(map(int, input().split()))
ans = []
if M == 0:
    print(N)
    exit()
c = N
L = list(map(int, input().split()))
while True:
    if c not in L:
        ans.append(c)
        break
    else:
        c += 1
c = N
while True:
    if c not in L:
        ans.append(c)
        break
    else:
        c -= 1
if abs(ans[0] - N) >= abs(ans[1] - N):
    print((ans[1]))
elif abs(ans[0] - N) < abs(ans[1] - N):
    print((ans[0]))

N, M = list(map(int, input().split()))
L = list(map(int, input().split()))
if N not in L:
    print(N)
    exit()
c = N
d = N
while True:
    if c not in L:
        break
    else:
        c -= 1
while True:
    if d not in L:
        break
    else:
        d += 1
if abs(d - N) >= abs(c - N):
    print(c)
else:
    print(d)

-ans = [] -if M == 0: +L = list(map(int, input().split())) +if N not in L: -L = list(map(int, input().split())) +d = N -        ans.append(c) -        break -    else: -        c += 1 -c = N -while True: -    if c not in L: -        ans.append(c) -if abs(ans[0] - N) >= abs(ans[1] - N): -    print((ans[1])) -elif abs(ans[0] - N) < abs(ans[1] - N): -    print((ans[0])) +while True: +    if d not in L: +        break +    else: +        d += 1 +if abs(d - N) >= abs(c - N): +    print(c) +else: +    print(d)