peterverebics/CodeNet_Python_118 huggingface dataset:
x,n = list(map(int, input().split()))
p = list(map(int, input().split()))

if p.count(x)==0:
  print(x)
else:
  a = 1
  while True:
    x1,x2 = x-a,x+a
    if p.count(x1)==0:
      print(x1)
      break
    elif p.count(x2)==0:
      print(x2)
      break
    else:
      a += 1
x,y = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(0,101):
  no = x-i
  if ps.count(no) == 0 & (no > 0):
    print(no)
    exit()
  no = x+i
  if ps.count(no) == 0 & (no < 101):
    print(no)
    exit()
x, n = map(int, input().split())
ans = 0
if n == 0: print(x)
else:
    p_i = list(map(int, input().split()))
    for val in range(101):
        minv = x - val
        maxv = x + val
        if minv not in p_i:
            print(minv)
            break
        elif maxv not in p_i:
            print(maxv)
            break
        else: 
            ans += 1
X, N = map(int, input().split())
p = list(map(int, input().split()))

c = 0
while True:
    if X - c not in p:
        print(X - c)
        break
    elif X + c not in p:
        print(X + c)
        break
    c += 1
import numpy as np

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

P = set(P)
All = set( np.arange(0,102) )
Q = np.array(list(All-P))

Q_X = np.absolute( Q-X )
ans = Q[ np.argmin(Q_X ) ]

print(ans)
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)
import numpy as np

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

P = P - X

for i in range(0, X + 1):
    if i not in P or -i not in P:
        if -i not in P:
            ans = X - i
        else:
            ans = X + i
        break

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

if n!=0:
  p_list = list(map(int, input().split()))

  res = set(range(102)) - set(p_list)
  res = [(abs(r-x), r) if r<=x else (abs(r-x)+0.5, r)
         for r in res]
  res = sorted(res, key=lambda r: r[0])

  print(res[0][1])
else:
  print(x)
x, n = list(map(int, input().split()))
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
d = 1e9
ans = 0
for e in range(200, -1, -1):
  dd = abs(e - x)
  if e not in p and dd <= d:
    d = dd
    ans = e
print(ans)
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x, n = map(int, input().split())
    P = set(list(map(int, input().split())))
    res = 0
    mi = f_inf
    for i in range(-200, 200):
        if i not in P:
            if abs(x - i) < mi:
                mi = abs(x - i)
                res = i
    print(res)


if __name__ == '__main__':
    resolve()
X,N=map(int,input().split())
*P,=sorted(map(int,input().split()))

from bisect import bisect_left

if N==0:
    t=X
else:
    l = bisect_left(P, X)
    for i in range(100):
        t=X-i
        if l-i<0 or t!=P[l-i]: break
        t=X+i
        if N<=l+i or t!=P[l+i]: break
print(t)
x,n = map(int,input().split())
p = list(map(int,input().split()))

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

for i in range(1000):
    right = x-i
    left = x+i

    if right not in P:
        ans = right
        break

    if left not in P:
        ans = left
        break
print(ans)
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()

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

exist = [False] * 102
for pi in p:
  exist[pi] = True
  
minabs = X
ans = 0
for i in range(102):
  if exist[i]:
    continue
  if abs(X-i) < minabs:
    ans = i
    minabs = abs(X-i)
    
print(ans)
x, n = map(int, input().split())
P = input().split()

ng_map = {}
for p in P:
    ng_map[int(p)] = True

min_val = 999
candidate = x
for i in range(102):
    if i in ng_map:
        continue
    val = abs(x - i)
    if val < min_val:
        candidate = i
        min_val = val
print(candidate)
X, N = map(int, input().split())
p = list(map(int, input().split()))
if N==0:
	p = [0]
r = 0
n = 0
while True:
    a = X+n
    if a not in p:
        b = a
        r = 1
    a = X-n
    if a not in p:
        b = a
        r = 1
    if r == 1:
        break
    else:
        n +=  1
print(b)
import sys
a=input()
a0=a.split()
x=int(a0[0])
n=int(a0[1])
if n==0:
    print(x)
    sys.exit()
p=input()
pl=list()
p=p.split()
k=-1
for i in range(n):
    pl.append(int(p[i]))
for i in range(102):
    q=i in pl
    if q==False :
        if abs(i-x)<abs(k-x):
            k=i
        else:
            print(k)
            sys.exit()
print(k)
# 初期入力
import sys
input = sys.stdin.readline
X,N = (int(i) for i in input().split())
if N !=0:
    p = list(map(int, input().split()))
elif N ==0:
    p=[-1]
p.sort()
#
ans =[]
for i in range(-1,102):
    if i not in p:
        ans.append((abs(i-X),i))
ans.sort()
print(ans[0][1])
import sys
x,n = map(int, sys.stdin.readline().rstrip("\n").split())
p = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
num = [i for i in range(-200,200)]
for i in range(n):
    num.remove(p[i])
if not num:
    pass
elif x in num:
    print(x)
else:
    d = 1
    while True:
        if x-d in num:
            print(x-d)
            break
        elif x+d in num:
            print(x+d)
            break
        else:
            d += 1
import bisect
x,b=map(int,input().split())
arr=list(map(int,input().split()))
if x not in arr:
    print(x)
    quit()
for i in range(x+1,102):
    if i not in arr:
        ma=i
        break
for i in range(x-1,-2,-1):
    if i not in arr:
        mi=i
        break
if x-mi<=ma-x:
    print(mi)
else:
    print(ma)
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

p = list(map(int, input().split()))
count = 0
res = 0
while True:
    before = X - count
    after = X + count
    if before not in p:
        res = before
        break
    elif after not in p:
        res = after
        break
    count += 1
print(res)
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    X, N = map(int, input().split())
    A = set(map(int, input().split()))

    for i in range(1000):
        if not X-i in A:
            print(X-i)
            break
        elif not X+i in A:
            print(X+i)
            break

if __name__ == '__main__':
    main()
X,N = map(int, input().split())
P = list(map(int, input().split()))

min = 51

for i in range(102):
    if i not in P and abs(X-i) < min:
        min = abs(X-i)
        ans = i

print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))
diff = 101 - x
ans = 101
for i in range(-1, 101):
    if i in p:
        continue
    if abs(i - x) < diff:
        diff = abs(i - x)
        ans = i
    elif abs(i - x) == diff:
        ans = min(ans, i)
print(ans)
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(N!=0):
    for a in lst:
         fl.append(int(a))
for a in range(101):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break
x,n,*l=map(int,open(0).read().split())
l=set(l)
t=101
for i in range(102):
  if i not in l and abs(i-x)<t: a,t=i,abs(i-x)
print(a)
X,N=map(int,input().split())
A=set(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
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
base = 1000
for i in range(0, 102):
  if abs(a[0]-base)>abs(a[0]-i) and i not in b:
    base = i
print(base)
# C Forbidden List

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

  for i in range(100):
    if x-i not in p:
      print(x-i)
      break
    elif x+i not in p:
      print(x+i)
      break
else:
  print(x)
def _main(x, p_list):
    p_set = set(p_list)
    diff = 0
    while True:
        t_minu = x - diff
        if t_minu not in p_set:
            print(t_minu)
            break

        t_plus = x + diff
        if t_plus not in p_set:
            print(t_plus)
            break
        diff += 1


# if __name__ == "__main__":
x_a, n_a = map(int, input().split())
p_list_a = map(int, input().split())
_main(x_a, p_list_a)
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  for x in ans:
    if x not in p:
      print(x)
      exit()
  ans+=[-1,1]
x, N = map(int, input().split())
p = list(map(int, input().split()))

min =10000
temp = 0
num = 10000

for i in range(-1000, 1000):
  temp = abs(x- i)
  
  if temp < min and i not in p:
    min = temp
    num = i
    
print(num)
x,n=map(int, input().split())
p = list(map(int, input().split()))
p=sorted(p)
last=1000
zettai=1000
for i in range(0, 102):
    if i not in p:
        if zettai>abs(i-x):
            zettai=abs(i-x)
            last=i
print(last)
x, n = map(int, input().split())
A = list(map(int, input().split()))

diff = 10000
candidate = -100000
for i in range(-101, 102):
    if abs(i - x) < diff and i not in set(A):
        diff = abs(i - x)
        candidate = i
print(candidate)
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    dat = list(map(int, input().split()))

    for i in range(200):
        a = x - i
        if a not in dat:
            print(a)
            break
        a = x + i
        if a not in dat:
            print(a)
            break
x,n = map(int,input().split())
v = list(map(int,input().split()))

for i in range(1,100):
  if x not in v:
    print(x)
    break
  if x-i not in v:
    print(x-i)
    break
  elif x+i not in v:
    print(x+i)
    break
X, N = map(int, input().split())

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

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

for i in range(102):
  a = X + i
  b = X - i
  if b not in p:
    print(b)
    exit(0)
  if a not in p:
    print(a)
    exit()
X,N=map(int,input().split())
if(N==0):
  print(X)
  exit()
P= list(map(int,input().split()))
c=-100
ans=100000
for i in range(200):
  a=0
  for i in range(200):
    if (abs(X-c)>=abs(X-c-a)):
      if not (c+a in P):
        
        if (abs(X-ans) >=abs(X-c-a)):
          ans=c+a
          
          
    a+=1
  c+=1
if (ans>X):
  if not(X-ans+X in P):
    ans=X-ans+X
print(ans)
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  for i in range(100):
    if X+i not in p:
      if X-i not in p:
        print(X-i)
        break
      print(X+i)
      break
    if X-i not in p:
      print(X-i)
      break
import sys

x,n = map(int,input().split())
if n == 0:
	print(x)
	sys.exit()
p = list(map(int,input().split()))
p.sort()

num = 0
ans = 10 ** 9
for i in range(102):
	if num < len(p) and i == p[num]:
		num += 1
		continue
	if ans > abs(x-i):
		ans = abs(x-i)
		res = i

print(res)
import math
X, N = map(int, input().split())
P = list(map(int, input().split()))
ans_1 = X
ans_2 = X
while True:
    if ans_1 not in P:
        print(ans_1)
        exit()
    ans_1 -= 1

    if ans_2 not in P:
        print(ans_2)
        exit()
    ans_2 += 1
x, n = map(int, input().split())
P = list(map(int, input().split()))

notP = list(range(-10, 110))
for p in P:
    notP.remove(p)
ans = min(notP, key=lambda y: abs(x - y))
print(ans)
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  lst=sorted(map(int,input().split()))
  dis=200
  ans=100
  for i in range(102):
    temp=abs(x-i)
    if temp<dis and i not in lst:
      dis=temp
      ans=i
  print(ans)
x, n = map(int, input().split())
try:
  lst = list(map(int, input().split()))
except:
  lst = []
  
flg = 0
if x not in lst or lst == []:
  print(x)
else:
  for _ in range(1, 101):
    mx = max(x - _, 0)    
    mn = min(x + _, 101)
    if mx not in lst:
      print(mx)
      break
    elif mn not in lst:
      print(mn)
      break
X, N = map(int, input().split(" "))

if N > 0:
  p = list(map(int, input().split(" ")))
else:
  p = []

go = True
absolute = 1
plus = True

if X not in p:
  print(X)
else:
  while go:
    if plus:
      target = X - absolute
      if target not in p:
        print(target)
        go = False
      plus = False
    else:
      target = X + absolute
      if target not in p:
        print(target)
        go = False
      absolute += 1
      plus = True
# # -*- coding: utf-8 -*-
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
    exit()

P = set((map(int, input().split(' '))))

ans, min_diff = None, float('inf')
for n in range(102):
    if n in P:
        continue

    diff = abs(X - n)
    if diff < min_diff:
        min_diff = diff
        ans = n

print(ans)
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
x, n = map(int, input().split())
not_p = []
if n != 0:
    p = list(map(int, input().split()))
    not_p = [i for i in range(201) if i not in p]
else:
    not_p = [i for i in range(201)]

mn = 101
ans = 100
for i in not_p:
    d = abs(x - i)
    if mn > d:
        mn = d
        ans = i

print(ans)
x, n = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  print(100)
  exit()
old_diff = 10000
for i in range(-110, 110):
  if i in p:
    continue
  else:
    diff = abs(x-i)
    if diff < old_diff:
      ans = i
      old_diff = abs(x-i)

try:
  print(ans)
except:
  print()
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    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
X,N = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N):
    if not (X-i in P):
        print(X-i)
        exit()
    elif not (X+i in P):
        print(X+i)
        exit()
if N == 0:
    print(X)
else:
    print(0)
x,n=map(int,input().split())
p=list(map(int,input().split()))
a=[1000]*102
for i in range(102):
    if i not in p:
        a[i]=abs(x-i)
print(a.index(min(a)))
X,N = 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 os

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

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

mini = 0
min = 1000
for b in range(-200,200):
    if min>abs(x-b):
        if b not in p:
            min = abs(x-b)
            mini = b

print(mini)
x,n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

for i in range(x+1):
    if x - i not in p:
        ans = x - i
        break
    elif x + i not in p:
        ans = x + i
        break

print(ans)
#ABC170 C 通せず
x, n = map(int, input().split())
seisulist = list(map(int, input().split()))
numlist = [i for i in range(0,102) if i not in seisulist]
xretu = [x]*len(numlist)
hikizan = [abs(s-t) for (s, t) in zip(numlist, xretu)]
sa = min(hikizan)
if x-sa not in seisulist:
    print(x-sa)
else:
    print(x+sa)
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))

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

for i in range(110):
    if (x-i) not in p:
        print(x-i)
        sys.exit()
    if (x+i) not in p:
        print(x+i)
        sys.exit()
X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = X
for i in range(101):
    ans = X - i
    if ans in p:
        ans = X + i
        if ans in p:
            continue
        else:
            break
    else:
        break

print(ans)
X, N = map(int, input().split())
p = [i for i in map(int, input().split())]

for i in range(0,101):
    if (X-i in p) == False: # pの中にX-iは無い場合
        print(X-i)
        break
    elif (X+i in p) == False: # pの中にX+iは無い場合
        print(X+i)
        break
X,N = [int(i) for i in input().split()]

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

ans = 0
m = 0
while True :
  if not X + m in p:
    if not X - m in p:
      ans = X-m
      break
    else :
      ans = X+m
      break
  if not X - m in p :
    ans = X-m
    break
  m += 1
  
print(ans)
X,N = map(int,input().split())
P = list(map(int,input().split()))

for n in range(100):
  if X-n not in P:
    print(X-n)
    break
  if X+n not in P:
    print(X+n)
    break
X, N = map(int, input().split())
P = set(map(int, input().split()))

for diff in range(1000):
  if X - diff not in P:
    print(X - diff)
    break
  elif X + diff not in P:
    print(X + diff)
    break
x, n = map(int, input().split())
if n > 0:
	p = list(map(int, input().split()))
else:
	p = []

distance = 1000
foundminimum = None
for i in range(102):
	if i in p:
		continue
	if distance > abs(x - i):
		distance = abs(x - i)
		foundminimum = i

print(foundminimum)
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = set(map(int, input().split()))
    d = 0
    while True:
    	if x-d not in p:
    		print(x-d)
    		break
    	if d+x not in p:
    		print(d+x)
    		break
    	d+=1
X, N = map(int, input().split())
if N > 0:
    p = list(map(int, input().split()))

    move = 0
    while True:
        minus_check = X - move
        if minus_check not in p:
            print(minus_check)
            break

        pulus_check = X + move
        if pulus_check not in p:
            print(pulus_check)
            break

        move += 1
else:
    print(X)
x,n = map(int,input().split())
p = list(map(int,input().split()))

num = []
for i in range(102):
    num.append(i)
for j in range(n):
    num.remove(p[j])

a = 1000000000000
b = 0
for k in range(102-n):
    if(abs(x-num[k]) < a):
        a = abs(x-num[k])
        b = num[k]

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

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

for i in range(100):
    q = X - i
    if q not in P:
        print(q)
        break
    q = X + i
    if q not in P:
        print(q)
        break
x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))
p = [-1] + p + [102]
import bisect
p.sort()
i = bisect.bisect_left(p,x)
if p[i] != x:
    print(x)
    exit()

for h in range(102):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()
x, n = map(int, input().split())
p = list(map(int, input().split()))

if not x in p:
    print(x)
    exit()
up = x + 1
down = x - 1
while True:
    if not down in p:
        print(down)
        exit()
    elif not up in p:
        print(up)
        exit()
    up += 1
    down -= 1
X,N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
nlist = [0 for i in range(105)] 
for i in p:
    nlist[i]=1
for i in range(max(X+1,100-X+1)):
    
    if X-i>=0:
        if nlist[X-i] == 0:
            result = X-i
            break
    if X+i<=101:
        if nlist[X+i] == 0:
            result = X+i
            break
print(result)
x, n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))
for i in range(100):
  if not x-i in p:
    print(x-i)
    break
  elif not x+i in p:
    print(x+i)
    break
import bisect
x,n = map(int,input().split())
p = list(map(int,input().split()))
lis = []
for i in range(110,-50,-1):
    if i not in p:
        lis.append(i)
m = 10000
ans = 0
for i in lis:
    if abs(x-i)<=m:
        m = abs(x-i)
        ans = i

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

for i in range(200):
    y,yy = X-i,X+i
    if y not in P:
        print(y)
        break
    elif yy not in  P:
        print(yy)
        break
X,N = list(map(int, input().split()))
if(N==0):
  print(X)
else:
  p = list(map(int, input().split()))
  now1 = X
  now2 = X
  while(1):
    if(now1 not in p):
      print(now1)
      break
    elif(now2 not in p):
      print(now2)
      break
    now1 -= 1
    now2 += 1
X,N,*P=map(int,open(0).read().split())
for i in range(100):
  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()))

abs_list = []

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

for i in range(0,150):
    j,k = abs(X - i), X +i
    if j not in P:
        print(j)
        break
    if k not in P:
        print(k)
        break
x, n = list(map(int, input().split()))
if not n:
  print(x) 
else:
  l = list(map(int, input().split()))
  dic = {} 
  for ll in l: dic[ll] = 1
  i = 0
  while True:
    if not dic.get(x-i,0):
      print(x-i)
      break
    elif not dic.get(x+i, 0):
      print(x+i) 
      break
    i+=1
x, n = map(int,input().split())

if n != 0:
    p = list(map(int,input().split()))
else:
    p = []

result = []

i = 0

while len(result) == 0:
    if not (x - i in p):
        result.append(x - i)
    if not (x + i in p):
        result.append(x + i)
    
    i += 1

print(int(min(result)))
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
P = list(map(int, input().split()))

length = 102
ans = 102
for i in range(-100,201):
    if not (i in P):
        if abs(x-i)<length:
            length = abs(x-i)
            ans = i

print(ans)
X, N = map(int, input().split())
List = list(map(int, input().split()))
if not X in List:
  ans = X
else:
  n = 1
  while True:
    if not (X - n) in List:         
      ans = X - n
      break
    elif not (X + n) in List:
      ans = X + n
      break
    else:
      n +=1
print(ans)
X,N = map(int, input().split())
if N ==0:
  print(X)
  exit() 
if N !=0:
  p = list(map(int, input().split()))
if p.count(X) == 0:
  print(X)
  exit()
for a in range(1000):
  if p.count(X-a) ==0:
    print(X-a)
    exit()
  elif p.count(X+a) ==0:
    print(X+a)
    exit()
x,n=map(int,input().split())
if n!=0:
    p=list(map(int,input().split()))
    dif=1000
    ans=-1
    for i in range(0,102):
        if i not in p:
            if abs(x-i)<dif:
                ans=i
                dif=abs(x-i)
    print(ans)
else:
    print(x)
a,b=map(int,input().split())
s = list(map(int, input().split()))
t = 0
h = 0
if b ==0:
    print(a)
else:
    for i in range(a,a+2+b):
        if not i in s:
            t = i
            break
    for i in range(a-1,a-2-b,-1):
        if not i in s:
            h = i
            break
    if abs(t-a)>=abs(h-a):
        print (h)
    else:
        print(t)
x, n = map(int, input().split())
p = list(map(int, input().split()))

temp = x
d = 0

while 1:
    if temp - d not in p:
        print(temp - d)
        exit()
    if temp + d not in p:
        print(temp + d)
        exit()
    d += 1
X, N = map(int, input().split())

if N == 0:
  print(X)
  
else:
  P = list(map(int, input().split()))
  A = [0]
  for i in range(1, 102):
    if (i in P) == False:
      A.append(i)
      
  c = 101
  for j in range(len(A)):
    if abs(X - A[len(A)-int(j)-1]) <= abs(X - c):
      c = A[len(A)-int(j)-1]
    else:
      c = c
  print(c)
x, n = map(int, input().split())
ps = list(map(int, input().split()))

i = 0
while True:
  if not (x - i) in ps:
    print(x - i)
    break
  if not (x + i) in ps:
    print(x + i)
    break
  i += 1
from sys import stdin
import sys

MAX_N = 100;

X, N = [int(x) for x in stdin.readline().rstrip().split()]
if N==0:
  print(X)
  sys.exit()
p = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(MAX_N//2+1):
  a=X-i
  if not a in p:
    print(a)
    break
  a=X+i
  if not a in p:
    print(a)
    break
X,N=map(int,input().split())
p=[0]*N
p=list(map(int,input().split()))
mixmix=float('inf')
hozon=-1
if(p.count(X)!=1):
    print(X)
    exit()
for i in range(1,101):
    if(p.count(X-i)!=1):
        print(X-i)
        exit()
    elif(p.count(X+i)!=1):
        print(X+i)
        exit()
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 = map(int,input().split())
p = list(map(int,input().split()))
y = 0
z = 0
while y == 0:
    a = x + z
    b = x - z
    if a in p and b in p:
        z += 1
    elif a not in p and b in p:
        print(a)
        y = 4
    elif b not in p:
        print(b)
        y = 5