peterverebics/CodeNet_Python_118 huggingface dataset:
import sys
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

if n == 0:
    print(x)
    sys.exit()

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(i)

nip_temp = []
for i in not_in_p:
    nip_temp.append(abs(x-i))

address = nip_temp.index(min(nip_temp))
print(not_in_p[address])
X, N = map(int, input().split())
i = list(map(int, input().split()))
if X not in i:
    print(X)
else:
    n = 1
    while n <=N+1:
        if X - n not in i:
            print(X - n)
            break
        else:
            if X+n not in i:
                print(X+n)
                break
        n +=1
X,N=map(int,input().split())
p=list(map(int,input().split()))

for i in range(110):
    if X-i not in p:
        print(X-i)
        exit()
    if X+i not in p:
        print(X+i)
        exit()
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
tmp = []

for i in range(-1, 103):
    if i not in p:
        tmp.append((abs(i - x), i))

print(min(tmp)[1])
X, N = map(int, input().split())
# p = list(map(int, input().split()))

if N == 0:
    input()
    print(X)
    exit(0)
else:
    p = list(map(int, input().split()))
    for i in range(10000):
        if X - i not in p:
            print(X - i)
            exit(0)
        elif X + i not in p:
            print(X + i)
            exit(0)
X, N = map(int,input().split())
P = list(map(int,input().split()))

if N == 0:
    print(X)
    exit()

for i in range(N+1):
    if X - i not in P:
        print(X-i)
        exit()
    elif X + i not in P:
        print(X+i)
        exit()
print(-1)
X, N = map(int, input().split())
p = list(map(int, input().split()))

for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break
#C
x, n = map(int, input().split())
if n ==0:
    print(x)
else:
    p = list(map(int, input().split()))
    num = list(range(-1, 102))

    num_removed=num
    for i in range(len(p)):
        num_removed=[num_removed for num_removed in num_removed if num_removed != p[i]]

    num_list=[]
    for i in num_removed:
        num_list.append(abs(x-i))

    min_index=min([i for i, j in enumerate(num_list) if j == min(num_list)])

    print(num_removed[min_index])
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

import itertools

X,N = map(int,readline().split())
p = list(map(int,readline().split()))
ans = -INF
now = INF
for i in range(-10,105):
    if i not in p:
        if now > abs(X-i):
            ans = i
            now = abs(X-i)
print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))

i = 0
while True:
    if not (x - i) in p:
        print(x-i)
        break
    if not (x + i) in p:
        print(x+i)
        break
    i += 1
x, n = map(int, input().split())
p_list = [i for i in map(int, input().split())]
p_list.sort()
plus_count = 1
minus_count = -1
while True:
    m_p = x + minus_count in p_list
    p_p = x + plus_count in p_list
    if x not in p_list:
        print(x)
        break
    elif m_p is False:
        print(x + minus_count)
        break
    elif p_p is False:
        print(x + plus_count)
        break
    else:
        minus_count -= 1
        plus_count += 1
x,n = map(int,input().split())
P = list(map(int,input().split()))

for i in range(102):
  xl = x - i
  xr = x + i
  if xl not in P:
    print(xl)
    break
  elif xr not in P:
    print(xr)
    break
import math as mt
#import numpy as np

def ro(n):
  return mt.floor(mt.sqrt(n))
def ya():
  print("Yes")
  return
def na():
  print("No")
  return


x,n=map(int,input().split())
if n>0:
  lis=list(map(int,input().split()))
  lis.sort()
#n=int(input())
#s=input()
kai=1

while 1:
  if n==0:
    break
  if not x in lis:
    break
  x-=kai
  kai+=1
  if not x in lis:
    break
  x+=kai
  kai+=1
print(x)
x,n = map(int,input().split())
p = list(map(int,input().split()))
zettaiti = float("inf")
for i in range(102):
    if i not in p:
        zettaiti2 = abs(i - x)
        if zettaiti > zettaiti2:
            zettaiti = zettaiti2
            ans = i
print(ans)
x,n=map(int,input().split())
s=input()
if n!=0:
  l=list(map(int,s.split()))
  cnt=0
  ans=0
  while True:
    if x-cnt in l:
      if x+cnt in l:
        cnt=cnt+1
      else:
        ans=x+cnt
        break
    else:
      ans=x-cnt
      break
  print(ans)
else:
  print(x)
import sys

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

tmp1 = 201
tmp2 = 201

for i in range(0,100):
  if X-i not in p:
    tmp1 = X-i
  elif X+i not in p:
    tmp2 = X+i
  if tmp1 != 201 or tmp2 != 201:
    print(min(tmp1,tmp2))
    sys.exit()
x, n = map(int, input().split())

if n == 0:
  print(x)

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

  xu = x
  uc = 0
  while xu in p:
    xu += 1
    uc += 1

  xd = x
  dc = 0
  while xd in p:
    xd -= 1
    dc += 1
  
  if uc < dc:
    print(xu)
  else:
    print(xd)
n,m = map(int,input().split())
if(m>0):
  l = list(map(int,input().split()))
  i=n
  j=n
  while(i in l):
    i-=1
  while(j in l):
    j+=1
  if(abs(n-i)<abs(n-j)): print(i)
  elif(abs(n-i)>abs(n-j)): print(j)
  else: print(min(i,j))
else: print(n)
x, n = map(int, input().split())
ps = set(map(int, input().split()))

if x not in ps:
   print(x)
   exit()

b, u = x, x
while True:
   b, u = b-1, u+1
   if b not in ps:
      print(b)
      exit()
   if u not in ps:
      print(u)
      exit()
import sys
x,n = map(int,input().split())
p = list(map(int,input().split()))
val = x
val_neg = x
val_pos = x
i = 1
while True:
    if val not in p:
        print(val)
        sys.exit()
    else:
        if val_neg not in p:
            print(val_neg)
            sys.exit()
        elif val_pos not in p:
            print(val_pos)
            sys.exit()
        else:
            val_neg -= i
            val_pos += i
inp = list(map(int,input().split()))
x=inp[0]
n=inp[1]
inp = list(map(int,input().split()))
from collections import Counter
c=Counter(inp)
if c[x]==0:
  print (x)
else:
  i=1
  while (1):
    if c[x-i]==0:
      print (x-i)
      break
    elif c[x+i]==0:
      print (x+i)
      break
    i+=1
X, N = list(map(int,input().split()))
p = list(map(int,input().split()))

v = 0
if N == 0:
    print(X)
else:
    while True:
        res = X - v
        if not res in p:
            break
        res = X + v
        if not res in p:
            break
        v += 1
    print(res)
x, n = map(int, input().split())
P = set(map(int, input().split()))
kouho = x
for i in range(100):
    kouho1 = kouho - i
    kouho2 = kouho + i
    if kouho1 not in P:
        print(kouho1)
        exit()
    elif kouho2 not in P:
        print(kouho2)
        exit()
print("error")
a = list(map(int,input().split()))
x = a[0]
n = a[1]
if n>0:
  b = list(map(int,input().split()))
  c = list(range(-n,101+n))

  
  for i in range(n):
    if b[i] in c:
      c.remove(b[i])

  
  k = 1000
  kn = 0

  for i in range(len(c)):
    if k>abs(x-c[i]):
      k = x-c[i]
      kn = c[i]
  print(kn)
else:
  print(x)
x,n=map(int,input().split())
p=list(map(int,input().split()))
y=x
z=x
if x not in p:
    print(x)
    exit()
for i in range(2*len(p)):
    y-=1
    z+=1
    if y not in p:
        print(y)
        exit()
    if z not in p:
        print(z)
        exit()
x,n= map(int,input().split())
p = list(map(int,input().split()))
ans,i = 0,0

while True:
    if x-i not in p:
        ans = x-i
        break
    if x+i not in p:
        ans = x+i
        break
    i = i+1
    
print(ans)
x,n = map(int,input().split())
p = list(map(int,input().split()))
b = [1]*201
for a in p:
    b[a]=0

wk = 999
idx = 0
for i in range(201):
    if wk > abs(x - b[i]*i):
        wk1 = abs(x - b[i]*i)
        idx = i
    wk = wk1

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

i = 0
while True:
  if (X - i) not in p:
    print((X - i))
    break
  elif (X + i) not in p:
    print((X + i))
    break
  i += 1
x,n=[int(x) for x in input().split()]
if n!=0:
    p=[int(x) for x in input().split()]
    l=list(range(110))
    for i in p:
        l.remove(i)
    L=[]
    for i in l:
        L.append(abs(i-x))
    m=min(L)
    print(l[L.index(m)])
else:
    print(x)
x,y = map(lambda x:int(x),input().split(" "))
if y==0:
    print(x)
else:
    input_list = list(map(lambda x:int(x),input().split(" ")))
    for i in range(y+2):
        if x-i not in input_list:
            print(x-i)
            break
        elif x+i not in input_list:
            print(x+i)
            break
def resolve():
    x, n = [int(i) for i in input().split()]
    if n != 0:
        l = [int(i) for i in input().split()]
    c = 0
    while 1:
        if n == 0:
            print(x)
            break
        if not(x - c in l):
            print(x - c)
            break
        elif not(x + c in l):
            print(x + c)
            break
        c += 1
resolve()
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(0,200):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X not in p_list:
            print(str(X))
            break
X, N = map(int,input().split())
li = set(list(map(int,input().split())))
li = list(set(range(102)) - li)

li.sort(reverse=True)
n = 102

for i in li:
    m = abs(X - i)
    if m <= n:
        n = m
        k = i
print(k)
x, n = map(int, input().split())
p = list(map(int, input().split()) )

cnt = 0
while True:
    big = x + cnt
    small = x - cnt
    if small not in p:
        print(small)
        exit()
    if big not in p:
        print(big)
        exit()
    cnt += 1
X,N = map(int, input().split())


if N > 0:
    p = list(map(int,input().split()))
    
    for i in range(1000):
        if X-i not in p:
            print(X-i)
            break
        elif X+i not in p:
            print(X+i)
            break
    
    #y = [abs(i - X) for i in p]
    
else:
    input()
    print(X)
x, n = map(int, input().split())
nums = list(map(int, input().split()))

if n == 0:
  print(x)
  exit()

dif = 0

while True:
  if (x - dif) not in nums:
    print(x - dif)
    break
  if (x + dif) not in nums:
    print(x + dif)
    break
  dif += 1
x, n, *lst = map(int, open(0).read().split())
for i in range(x + 1):
  if x - i not in lst:
    print(x - i)
    quit()
  if x + i not in lst:
    print(x + i)
    quit()
X,N = map(int, input().split())
P = set(map(int, input().split()))

d = 10**9
ans = 0
for i in range(120) :
    if(i in P) :
        continue
    if(abs(X-i) < d) :
        ans = i
        d = abs(X-i)
print(ans)
#!/usr/bin/python
# -*- coding: utf-8 -*-

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


for x in range(0,101):
    if X-x not in p:
        print(X-x)
        exit()
    elif X+x not in p:
        print(X+x)
        exit()
X,N = map(int,input().split())
p = list(map(int,input().split()))
ans1 = X
ans2 = X

if X not in p:
    print(X)
    exit()

for i in range(len(p)):
    ans1 -= 1
    ans2 += 1
    if ans1 not in p:
        print(ans1)
        exit()
    if ans2 not in p:
        print(ans2)
        exit()
print(X)
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    L = list(map(int,input().split()))
    ans = []
    cur = 0
    while len(ans) == 0:
        temp_1 = x-cur
        temp_2 = x+cur
        if temp_1 not in L:
            ans.append(temp_1)
        if temp_2 not in L:
            ans.append(temp_2)
        cur += 1
    print(ans[0])
x,n = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]

for i in range(x+1):
    for j in [-1,1]:
        y = x + j * i
        if y in l:
            pass
        else:
            print(y)
            exit()
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

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

cnt = 0
while True:
    if cnt == 0 and x not in list_:
        print(x)
        break

    if x - cnt not in list_:
        print(x - cnt)
        break

    if x + cnt not in list_:
        print(x + cnt)
        break

    cnt += 1
import sys
import math
import itertools
x, n = map(int, input().split())
p = list(map(int, input().split()))
if (n == 0):
    print(x)
    sys.exit()
diff = 1000
ans = 0
p.sort()
diff=1000
for i in range(-110,110):
    if (i in p):
       continue
    else:
        if (abs(x - i) < diff):
            diff = abs(x - i)
            ans = i
print(ans)
x, n = map(int, input().split(' '))

if n == 0:
    print(x)
    exit()


p = set(map(int, input().split(" ")))

for i in range(100):
    if not x - i in p:
        print(x - i)
        exit()
    elif not x + i in p:
        print(x + i)
        exit()
x,n = map(int, input().split()) 

if n==0:
    print(x)
    exit()    

p = [int(x) for x in input().split()]

for i in range(150):
    if x-i not in p:
        print(x-i)
        exit()
    elif x+i not in p:
        print(x+i)
        exit()
N,M = map(int,input().split())
if M == 0:
  print(N)
else:
  c=list(map(int, input().split()))
  for i in range(N+1):
    for s in [-1,1]:
      a = N+s*i
      if c.count(a)==0:
      	print(a)
      	exit(0)
import sys
X, N = [int(x) for x in input().split()]
if N == 0:
    print(X)
    sys.exit()

p = [int(x) for x in input().split()]

p.sort()

t = []
t.append(p[0] - 1)

for i in range(p[0], p[N-1]+1):
    if i not in p:
        t.append(i)
t.append(p[N-1]+1)

_min = 1000000000000
res = 100000000000
for i in t:
    if abs(X - i) == _min:
        res = min(res, i)
    if abs(X - i) < _min:
        _min = abs(X - i)
        res = i

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

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

if N == 0:
    print(X)
    sys.exit()

p_set = set(P)

if not (X in p_set):
    print(X)
    sys.exit()

for i in range(1, 100):
    if not (X-i in p_set):
        print(X-i)
        break
    if not (X+i in p_set):
        print(X+i)
        break
x, n = map(int, input().split())
p = set(map(int, input().split()))

low = x
high = x
while True:
    if low not in p:
        print(low)
        break
    elif high not in p:
        print(high)
        break
    low -= 1
    high += 1
x, n = map(int, input().split())
p = list(map(int, input().split()))

diff = 1000
for i in range(-100, 110):
    if i in p:
        continue
    if abs(i - x) < diff:
        diff = abs(i - x)
        ans = i

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

if n == 0:
    print(x)
    exit()

p_li = list(map(int, input().split()))
p_li.sort()

ans = 999
for i in range(-1, 102):
    if not i in p_li:
        tmp = i

        if abs(x - ans) > abs(x - tmp):
            ans = i

print(ans)
lst1 = input().split()
lst2 = input().split()
key = int(lst1[0])
lst = []
for i in range(102):
    lst.append(i)
for i in lst2:
    lst.remove(int(i))
for i in range(len(lst)):
    if lst[i] > key:
        break
if lst[i] - key < key - lst[i-1]:
    print(lst[i])
else:
    print(lst[i-1])
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
p=list(map(int,input().split()))

for j in range(100):
    a1=x-j
    a2=x+j
    if a1 not in p:
        print(a1)
        exit()
    if a2 not in p:
        print(a2)
        exit()
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    p = list(map(int,input().split()))

    for i in range(n+2):
        if x-i in p:
            if x+i in p:
                a =0
            else:
                print(x+i)
                exit(0) 
        else:
            print(x-i)
            exit(0)
x,n=map(int,input().split())
p=list(map(int,input().split()))
tmp=1000
for i in range(-100,300):
    if not i in p:
        tmp=min(tmp,abs(x-i))
for i in range(-100,300):
    if abs(x-i) == tmp and not i in p:
        print(i)
        exit()
x, n = map(int, input().split())
if n == 0:
	print(x)
	exit()
p = list(map(int, input().split()))

s = set(p)
p = []
for x1 in range(-100, 200):
	if x1 in s:
		continue
	else:
		p.append(x1)
mind = abs(x - p[0])
pos = [p[0]]
for q in p:
	if abs(x - q) < mind:
		#print(q)
		mind = abs(x - q)
		pos = [q]
	elif abs(x - q) == mind:
		pos.append(q)
pos.sort()
print(pos[0])
import bisect
X,N=map(int,input().split())
if N==0:
    print(X)
    exit()
P=sorted(list(map(int, input().split())))
key=bisect.bisect_right(P,X)
small=101
large=0

for i in range(N):
    if P[key-1]-i not in P:
        small=P[key-1]-i
        break
for i in range(N):
    if P[key-1]+i not in P:
        large=P[key-1]+i
        break
print(small if abs(X-small)<=abs(X-large) else large)
X,N = list(map(int,input().split()))
P = set(map(int,input().split()))
cnt = 0
while True:
    if X-cnt not in P:
        print(X-cnt)
        break
    if X+cnt not in P:
        print(X+cnt)
        break
    cnt += 1
X,N=map(int,input().split())
*P,=map(int,input().split())

i=0
while 1:
    if X-i not in P:
        print(X-i)
        break
    if X+i not in P:
        print(X+i)
        break
    i+=1
X, N = map(int, input().split())
p_list = list(map(int, input().split()))

if N == 0: 
   print(X)
else:
   for i in range(0,100):
       if not X-i in p_list:
           print(X-i)
           break
       elif not X+i in p_list:
           print(X+i)
           break
#!/usr/bin/env python3

def ans(P, X):
    P = set(P)
    for i in range(200):
        if X - i not in P:
            return X-i 
        if X + i not in P:
            return X+i

X, N = input().split(' ')
X = int(X)
N = int(N)
if N == 0:
    print(X)
else:
    P = input().split(' ')
    P = [int(x) for x in P]

    print(ans(P, X))
import numpy as np

a=[input() for i in range(2)]
a1=a[0].split()
a2=a[1].split()
x=int(a1[0])
n=int(a1[1])

p=[int(i) for i in a2]

d_list=[]

for i in np.arange(-1,102):
	if i not in p:
		d=abs(i-x)
		d_list.append(d)

sa=min(d_list)

an=x-sa
an2=x+sa

if an in p:
	print(an2)

else:
	print(an)
x,y = map(int,input().split(" "))
if y == 0:
    print(x)
    exit()
ar = list(map(int,input().split(" ")))
if x not in ar:
    print(x)
else:
    a = x
    b = x
    while True:
        a -= 1
        if a not in ar:
            print(a)
            exit()
        b += 1
        if b not in ar:
            print(b)
            exit()
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)

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

m = [True] * (105)
for i in range(n):
  m[p[i]] = False

l = x
r = x

for i in range(105):
  if m[l] and m[r]:
    print(l)
    exit(0)
  if m[l] and not m[r]:
    print(l)
    exit(0)
  if not m[l] and m[r]:
    print(r)
    exit(0)
  l -= 1
  r += 1
x, n =map(int,input().split())
ps = list(map(int, input().split()))
a=100

if not(x in ps):
    print(x)
else:
    for i in range(100):
        if x+i in ps:
            b=100
        else:
            a=x+i
            break
    for j in range(100):
        if x-j in ps:
            b=100
        else:
            if a-x>=j:
                a=x-j
                break
    print(a)
import sys

X,N=map(int,input().split())
if N==0:
  print(X)
  sys.exit()
lis=[int(_) for _ in input().split()]
for i in range(200):
  s=X-i
  u=X+i
  if not(s in lis):
    print(s)
    sys.exit()
  if not (u in lis):
    print(u)
    sys.exit()
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()

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

ls = [i for i in range(102)]
for i in pn:
    ls[i] = 0

ls = list(set(ls))
ans = 0
m = 10**5
for j in ls:
    if abs(x - j) < m:
        m = abs(x - j)
        ans = j

print(ans)
import numpy

import sys
#整数xと長さn
x, n = map(int, input().split())

#入力される整数列 list
list = list(map(int, input().split()))

#入力確認
#print(x, n)
#print(list)

for i in range(101):
    if x - i not in list:
        print(x - i)
        sys.exit()
    elif x + i not in list:
        print(x + i)
        sys.exit()
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a,b=ml()
if(b==0):
    n=set()
else:
    n=ll()
    n=set(n)
r=0
for i in range(a,1001):
    if(i not in n):
        r=i
        break
l=0    
for i in range(a-1,-1,-1):
    if(i not in n):
        l=i
        break
if(abs(l-a)<=abs(r-a)):
    print(l)
else:
    print(r)
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
i = 0
while True:
    if x - i not in p:
        print(x-i)
        exit()
    if x + i not in p:
        print(x+i)
        exit()
    i += 1
a = input()

t, c = int(a.split(" ")[0]), int(a.split(" ")[1])

if not c:
    print(t)
else:
    b = input()
    lst = [int(x) for x in b.split(" ")]

    for i in range(c+2):
        if t - i not in lst:
            print(t - i)
            break
        if t + i not in lst:
            print(t + i)
            break
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
    else:
        ax = x
        while ax in P:
            ax += 1
        
        mx = x
        while mx in P:
            mx -= 1

        if abs(x-ax) < abs(x-mx):
            print(ax)
        else:
            print(mx)
def resolve():
    X, N = list(map(int, input().split()))
    P = list(map(int, input().split()))
    ans = float("inf")
    for i in range(0, 102):
        if i in P:
            continue
        if abs(X-ans) > abs(X-i):
            ans = i
        elif abs(X-ans) == abs(X-i):
            ans = min(ans, i)
    print(ans)


if '__main__' == __name__:
    resolve()
import sys

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

sa = 300

for i in range(102):
    if abs(i-x) < sa:
        if not((i) in p):
            sa = abs(i-x)
            ans = i
print(ans)
x,n = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

pidx = 0
ansabs = 1000
for i in range(102):
    if pidx < n and i == p[pidx]:
        pidx += 1
        continue
    if ansabs > abs(i - x):
        ansabs = abs(i - x)
        ans = i

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

if N==0:
  print(X)
  exit(0)
  
p = [int(i) for i in input().split()]

for i in range(101):
  for s in [-1,1]:
    a = X + i*s
    if a not in p:
      print(a)
      exit(0)
x,n = map(int, input().split())
num_list = list(map(int, input().split()))

for i in range(101):
    if (x-i) not in num_list:
        print(x-i)
        exit()

    if (x+i) not in num_list:
        print(x+i)
        exit()
x, n = map(int, input().split(" "))

if n == 0:
    print(x)
else:
    p = list(map(int, input().split(" ")))

    p_under = list(filter(lambda v: v<=x, p))
    p_upper = list(filter(lambda v: v>=x, p))
    p_under.sort(reverse=True)
    p_upper.sort()

    cnt = 0
    while(True):
        if x - cnt not in p_under:
            print(x - cnt)
            break
        if x + cnt not in p_upper:
            print(x + cnt)
            break
        cnt += 1
from typing import List


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


def solve(x: int, n: int, P: List[int]):
    plus = minus = x
    while True:
        if minus not in P:
            return minus
        elif plus not in P:
            return plus
        plus += 1
        minus -= 1


print(solve(x, n, P))
x, n = map(int, input().split())
p = list(map(int, input().split()))
sa = float("inf")
for i in range(-100, 201):
    if i not in p:
        sa = min(sa, abs(i - x))
if x - sa not in p and x + sa not in p:
    print(x - sa)
elif x - sa in p and x + sa not in p:
    print(x + sa)
elif x - sa not in p and x + sa in p:
    print(x - sa)
x, n = map(int, input().split())
p = list(map(int, input().split()))

flag = 0
i = 0
while (flag == 0):
    if (x - i) not in p:
        flag = 1
        print(x - i)
    elif (x + i) not in p:
        flag = 1
        print(x + i)
    else:
        i += 1