peterverebics/CodeNet_Python_118 huggingface dataset:
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))

P = set(P)

diff = float('INF')
ans = None
for i in range(-100, 300):
    if i in P:
        continue
    d = abs(X - i)
    if d < diff:
        diff = d
        ans = i

print(ans)
x, n = map(int, input().split())
apple = list(map(int, input().split()))
for i in range(101):
    a = x-i
    b = x+i
    if a not in apple:
        print(a)
        break
    elif b not in apple:
        print(b)
        break
    else:
        pass
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

p = list(map(int, input().split()))
pp = set(p)
numlist = [i for i in range(-1000, 1000)]
numlistt = set(numlist)
newlist = numlistt - pp
newlistt = list(newlist)
absn = 1000
ans = 1000
 
for i in newlistt:
    if absn > abs(X-i):
        ans = i
        absn = abs(X-i)
    elif absn == abs(X-i) and i < ans:
        ans = i
        absn = abs(X-i)

print(ans)
a, b= map(int, input().split())
lista= [int (x) for x in input().split()]

for i in range(102):
    if a-i not in lista:
        print(a-i)
        break
    elif a+i not in lista:
        print(a+i)
        break
X,N=map(int,input().split())
if N==0:
    print(X)
    exit()

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

D=[[]for i in range(201)]


for i in range(-99,102):
    D[i].append(i)
    D[i].append(abs(X-i))
#print(D)
    
T=sorted(D,key=lambda x:x[1])
#for i in range(N):
for i in range(201):
    if T[i][0] not in S:
        print(T[i][0])
        exit()
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  x,n =I()
  p = LI()
  for i in range(51):
    if x - i not in p:
      ans = x - i
      break
    if x + i not in p:
      ans = x + i
      break
  print(ans)
if __name__ == '__main__':
  main()
X,N = map(int,input().split())
p = list(map(int, input().split()))
n =max(X+1,N+1)

for i in range(n):
  if X-i not in p:
    print(X-i)
    break
  elif X+i not in p:
    print(X+i)
    break
  else:
    continue
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
else:
    p = set(map(int, input().split()))
q = set(range(min(p)-1,max(p)+2,1))
r = q - p
diff = 100
ans = 0
for i in r:
    if diff > abs(X-i):
        diff = abs(X-i)
        ans = i
print(ans)
x,n = map(int, input().split())
p = set(map(int, input().split()))
a = set(range(-200, 200))
b = a - p

mi = 10**6
ans = -1
for bi in b:
    if abs(bi - x) < mi:
        mi = abs(bi - x)
        ans = bi
print(ans)
A,B=list(map(int,input().split()))
if B==0:
   print(A)
   exit()
N=list(map(int,input().split()))
N=set(N)
S=0
l=float("Inf")
for i in reversed(range(A,A+101)):
   if i not in N:
      S=i
      l=abs(A-i)
for i in reversed(range(A-100,A+1)):
   if i not in N and l >= abs(A-i):
      S=i
      break
print(S)
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
p = list(map(int, input().split()))

ans_list = [i for i in range(102)]
for i in range(N):
    now = p[i]
    for j in range(len(ans_list)):
        if ans_list[j] == now:
            del ans_list[j]
            break
        
ans = 1000
k = 1000
for i in range(len(ans_list)):
    if abs(ans_list[i] - X) < ans:
        ans = abs(ans_list[i] - X)
        k = ans_list[i]

print(k)
x, n = map(int, input().split())
p = [int(v) for v in input().split()]
ans = None
if x not in p:
    ans = x
else:
    diff = 101
    for i in range(0, max(p) + 2):

        if abs(x - i) < diff and i not in p:
            ans = i
            diff = abs(x - i)
print(ans)
X, N = map(int, input().split())
h = list(map(int, input().split()))
ans = []
for i in range(0, N+1):
    if X+i not in h:
        ans.append(X+i)
    if X-i not in h:
        ans.append(X-i)
    if ans != []:
        break
print(min(ans))
x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
res=0
for i in range(102):
    if i not in p:
        if abs(x-res)>abs(x-i):
            res=i
print(res)
X,N = map(int,input().split())
p = list(map(int,input().split()))
p_set = set(p)

for i in range(100):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break
x, n = map(int, input().split())
p = list(map(int, input().split()))
s = 101
ans = 101
for i in range(-100,100+2):
    if not i in p:
        if s > abs(x-i):
            s = abs(x-i)
            ans = i
print(ans)
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

x, n = inm()
a = inl()
count = 1
if x not in a:
    print(x)
else:
    while True:
        if x - count not in a:
            print(x - count)
            break
        if x + count not in a:
            print(x + count)
            break
        count += 1
x,n = list(map(int,input().split()))
p = sorted(list(map(int,input().split())))

ab = 100
num = []
for i in range(102):
    if p.count(i)>0:
        continue
    abst = abs(i-x)
    if abst < ab:
        ab = abst
        num = [i]
    elif abst == ab:
        ab = abst
        num += [i]
print(min(num))
X,N = [int(i) for i in input().split()]
p = sorted([int(i) for i in input().split()], key=lambda x: x) if N > 0 else [0]

diffMin = 10**9 
minNum = -10**9
for i in range(0, 100+1+1):
  if i not in p and diffMin > abs( X-i ) :
     diffMin = min(diffMin,abs( X-i ))
     minNum = i
print(minNum)
import sys
input = sys.stdin.readline

def calc():
    x, n = [int(x) for x in input().split()]

    if n == 0:
        q = [x for x in range(102)]
    else:
        p = [int(x) for x in input().split()]
        q = [x for x in range(102) if x not in p]
    diffs = [abs(x - qk) for qk in q]
    mindiff = min(diffs)
    idx = diffs.index(mindiff)
    print(q[idx])

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

  min = 1000
  ans = 0
  for i in range(102):
    if abs(x-i)<min and (i in p)==False:
      min = abs(x-i)
      ans = i

  print(ans)
X,N = map(int,input().split())
if N ==0:
    print(X)
else:
    p = list(map(int,input().split()))
    x_min = 101
    num_list = list(range(102))
    for i in range(N):
        num_list.remove(p[i])
    for j in reversed(num_list):
        x = abs(j-X)
        if x_min >= x:
            x_min = x
            close=j
    print(close)
import sys
readline = sys.stdin.readline


def main():
    X, N = map(int, readline().rstrip().split())
    P = set(map(int, readline().rstrip().split()))

    for i in range(200):
        if X - i not in P:
            print(X - i)
            return
        if X + i not in P:
            print(X + i)
            return


if __name__ == '__main__':
    main()
from sys import stdin
input = stdin.readline


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

  min_ = float('inf')
  for i in range(102):
    if i not in P and abs(X - i) < min_:
      min_ = abs(X - i)

  cand = []

  for i in range(102):
    if i not in P and abs(X - i) == min_:
      cand.append(i)

  print(min(cand))


if(__name__ == '__main__'):
  main()
X,N=map(int,input().split())
P=[int(x) for x in input().split()]
index=0
while(1):
    if X-index not in P:
        print(X-index)
        break
    if X+index not in P:
        print(X+index)
        break
    index+=1
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=set(map(int,input().split()))
  for i in range(N+1):
    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 = {*map(int, input().split())}

ans = 1000
diff = 1000
for i in range(102):
  if i in p:
    continue
  if abs(x - i) < diff:
    diff = abs(x - i)
    ans = i
print(ans)
data = input().split()
x = int(data[0])
n = int(data[1])

p = input().split()
for i in range(n):
	p[i] = int(p[i])

if n == 0:
	print(x)
	exit()
if not x in p:
	print(x)
	exit()

for i in range(102)[1:]:
	if not (x-i) in p:
		print(x-i)
		exit()
	elif not (x+i) in p:
		print(x+i)
		exit()
INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

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

S = set([i for i in range(102)])
S = S - P

ans = -1
diff = INF
for s in sorted(S):
    if abs(s - X) < diff:
        ans = s
        diff = abs(s - X)

print(ans)
from sys import exit

def downsearch(X,list):
    if X not in list:
        return X
    else:
        return downsearch(X-1,list)

def upsearch(X,list):
    if X not in list:
        return X
    else:
        return upsearch(X+1,list)


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

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

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

d = downsearch(X,plist)
u = upsearch(X,plist)

if abs(X-d) <= abs(X-u):
    print(d)
else:
    print(u)
def gen(X):
    x = X
    yield x
    d = 1
    while True:
        yield X - d
        yield X + d
        d += 1
def main():
    X, N = map(int, input().split())
    P = set(map(int, input().split()))

    for x in gen(X):
        if x not in P:
            print(x)
            return

if __name__ == '__main__':
    main()
x,n=map(int,input().split())
if n==0:
	print(x)
	exit()
p=list(map(int,input().split()))
s=x-1
b=x+1
if x not in p:
	print(x)
else:
	while True:
		if s not in p:
			print(s)
			exit()
		s-=1
		if b not in p:
			print(b)
			exit()
		b+=1
x, n = map(int, input().split(" "))
v = [i for i in range(102)]
min_val = 100
ans_val = 0

if n != 0:
    p = list(map(int, input().split(" ")))    
    for index in p:
        v[index] = 101


for v_val in v:
    if(min_val > abs(v_val - x)):
        ans_val = v_val
        min_val = min(min_val, abs(v_val - x))
    #print(abs(v_val - x), end=" ")


#print("")
print(ans_val)
x,n = map(int,input().split())
if n != 0:
  l = list(map(int,input().split()))
else:
  l = []

m = 1e9
ans = None
for i in range(101,-2,-1):
  if i in l:
    continue
  if abs(x-i) <= m:
    m = abs(x-i)
    ans = i
print(ans)
X, N = map(int, input().split())
p = list(map(int, input().split()))

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

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

a = -1
if len(P) > 0:
    for p in range(0, 102):
        if abs(X - p) < abs(X - a) and (p not in P):
            a = p
else:
    a = X

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


if n <= 0:
    print(x)
else:
    p = list(map(int,input().split()))
    p.sort()
    p2 = [x for x in range(-200,200)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in p_p2_diff_list:
        val = abs(x - i)
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])
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)
        exit()
    elif not x+i in p:
        print(x+i)
        exit()
import sys

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

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

all_list = [int(x) for x in range(0, 102)]
target_list = sorted(list(set(list_p) ^ set(all_list)))

ans = [abs(num - X) for num in target_list]
# print(all_list)
# print(target_list)
# print(min(ans))
# print(ans.index(min(ans)))
print(target_list[ans.index(min(ans))])
x,n = map(int,input().split())
if n == 0:
  print(x)
else:
  ps= set(map(int,input().split()))
  diff = 0
  while(True):
    if x-diff not in ps:
      print(x -diff)
      break
    elif x + diff not in ps:
      print(x + diff)
      break
    diff +=1
X, N = map(int, input().split())
P = list(map(int, input().split()))
target = X
for i in range(1000):
    target = X - i
    if target not in P:
        break
    target = X + i
    if target not in P:
        break
print(target)
x, n = [int(e) for e in input().split()]
nums = [int(e) for e in input().split()]

ans = x
for i in range(2*n):
    if x-i not in nums:
        ans = x-i
        break
    elif x+i not in nums:
        ans = x+i
        break
    else:
        continue
print(ans)
x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:(abs(y-x),y)))
import sys

x, n, *ppp = map(int, sys.stdin.buffer.read().split())
ppp = set(ppp)

if len(ppp) == 0:
    print(x)
    exit()

s = min(ppp)
t = max(ppp)

ans = s - 1
y = abs(x - ans)
for z in range(s, t + 2):
    if z in ppp:
        continue
    d = abs(x - z)
    if d < y:
        ans = z
        y = d

print(ans)
X, N = map(int, input().split())
A = list(map(int, input().split()))
loki = 0
while loki >= 0:
    if A.count(X - loki) == 0:
        print(X - loki)
        loki = -1
    elif A.count(X + loki) == 0:
        print(X + loki)
        loki = -1
    else:
        loki += 1
import itertools
import copy
from collections import deque
import heapq
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int,input().split()))
check = {key:0 for key in p}
mi = copy.deepcopy(x)
ma = copy.deepcopy(x)
while True:
    if not mi in check:
        print(mi)
        exit()
    if not ma in check:
        print(ma)
        exit()
    mi -= 1
    ma += 1
x,n=map(int,input().split())
p=list(map(int,input().split()))
t=0
while t<=100:
    if x-t not in p:
        print(x-t)
        exit()
    if x+t not in p:
        print(x+t)
        exit()
    t += 1
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    l = list(map(int, input().split()))
    m = [i for i in range(102)]
    s = list(set(m) - set(l))
    answer_list = []
    for i in s:
        if i <= X:
            answer_list.append(X - i)
        else:
            answer_list.append(i - X)
    answer = min(answer_list)
    if X - answer in s:
        print(X - answer)
    else:
        print(X + answer)
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))

a = 100
b = 0
for i in range(0, 102):
    if i not in p and abs(x - i) < a:
        a = abs(x - i)
        b = i

print(b)
X, N = map(int,input().split())
if N != 0:
  ps = sorted(list(map(int,input().split())))
  # print(ps)
  min_num = 1000
  min_abs = 1000
  p_index = 0
  for i in range(0,102):
    if i == ps[p_index]:
      p_index += 1
      p_index %= N
    elif abs(i-X)<min_abs:
      min_num = i
      min_abs = abs(i-X)
  print(min_num)
else:
  print(X)
x,n = map(int,input().split())

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

s = 1000000000

for i in range(-100,102):
    if i in p:
        continue
    s = min(abs(x-i),s)
    

if not x-s in p:
    print(x - s)
else:
    print(x + s)
x, n = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
q = []
for i in range(102):
	if i not in p:
		q.append(i)
q.sort(key=lambda z: abs(z-x))
if len(q) < 2:
	print(q[0])
else:
	if abs(q[0] - x) == abs(q[1] - x):
		print(min(q[0], q[1]))
	else:
		print(q[0])
x, n = map(int, input().split())

if n==0:
  print(x)
else:
  p=list(map(int , input().split()))
  con=0
  anco=0
  
  for _ in range(0, 100):
    for i in range(n):
      if x-_==p[i]:
        con=1
      if x+_==p[i]:
        anco=1
    if con==0:
        print(x-_)
        break
    elif anco==0:
      print(x+_)
      break
    con=0
    anco=0
xn = list(map(int, input().split()))
if xn[1] == 0:
  print(xn[0])
  exit()
  
p = list(map(int, input().split()))

flag = 0
abs = 0

while flag == 0:
  test1 = xn[0] + abs
  test2 = xn[0] - abs
  if not test2 in p:
    flag = 2
  elif not test1 in p:
    flag = 1
  abs += 1

if flag == 1:
  print(test1)
else:
  print(test2)
x, n = map(int, input().split())
p = list(map(int, input().split()))
result = []
for i in range(102):
    if i in p:
        continue
    else:
        result.append([abs(i-x), i])
result.sort()
print(result[0][1])
pre = input().split()
X = int(pre[0])
N = int(pre[1])

if N == 0:
  print(X)
else:
  pre = input().split()
  p = [int(s) for s in pre]

  list = [0] * 102

  for i in range(len(p)):
    list[p[i]] = 1
  

  for i in range(55):
    if list[X-i] == 0:
      print(X-i)
      break
    if list[X+i] == 0:
      print(X+i)
      break
li = []
for i in range(102):
    li.append(i)
lis = set(li)
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
lia = list(map(int,input().split()))
lias = set(lia)
seta = lis - lias
li = list(seta)
li.reverse()
a = 1000
for i in range(102-n):
    if abs(li[i]-x) <= a:
        a = abs(li[i]-x)
        b = li[i]
print(b)
X,N = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

for d in range(X+1):
    for f in [-1,1]:
        a = X + d*f
        if p.count(a) == 0:
            print(a)
            exit()
import sys
X, N = map(int,input().split())
if N == 0:
  print(X)
  sys.exit()
p = set(map(int,input().split()))
for i in range(51):
  a = X - i
  if not(a in p):
    print(a)
    sys.exit()
  a = X + i
  if not(a in p):
    print(a)
    sys.exit()
x,n = [int(x) for x in input().split()]
p = set([int(x) for x in input().split()])


l,r = x,x
while True:
  if l not in p:
    print(l)
    exit()
  elif r not in p:
    print(r)
    exit()

  l-=1
  r+=1
x,n = map(int,input().split())
l = list(map(int,input().split()))
if n == 0:
    print(x)
    exit()
sa = 0
ansa,ansb = x,x
while ansa in l and ansb in l:
    ansa -= 1
    ansb += 1
if not ansa in l:
    print(ansa)
else:
    print(ansb)
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)
x, n = list(map(int, input().split()))
if n == 0:
  inputs = []
else:
  inputs = list(map(int, input().split()))
nums = [0] * 201
diff = 1000
n = 100
for i in inputs:
  nums[i] = 1
for i in range(0, 201):
  d = abs(i - x)
  if nums[i] == 1:
    continue
  if d < diff:
    diff = d
    n = i
print(n)
x, n = map(int, input().split())
p = list(map(int, input().split()))
p = set(p)

ans = 0
for i in range(102):
    if i not in p and abs(ans - x) > abs(i - x):
        ans = i

print(ans)
x,n=map(int,input().split())
p=list(map(int,input().split()))
a=[0]*102
for i in range(len(p)):
    a[p[i]]=1
sa=500
for j in range(len(a)):
    if a[j]==0 and sa>abs(x-j):
        m=j
        sa=abs(x-j)
print(m)
x,n=map(int,input().split())
if n!=0:
  a=list(map(int,input().split()))	
else:
  print(x)
  exit()
  
b=[]

for i in a:
  b.append(abs(i-x))

m=min(b)
  
if m==0:
  for i in range(max(b)+2):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()
else:
  print(x)
X, N = map(int, input().split())
if int(N) == 0:
    print(X)
else:
    Y = list(map(int, input().split()))
    x = int(X)
    for i in range(100):
        if x - i not in Y:
            print(x - i)
            break
        elif x + i not in Y:
            print(x + i)
            break
X,N = map(int,input().split())
P = set(map(int,input().split()))

o = []
for i in range(2 * X + 1):
    if i in P:
        continue
    o.append(abs(i-X)*10000+i)

print(min(o)%10000)
X, N = map(int, input().split())
*P, = map(int, input().split())
l = set([i for i in range(-200, 200)]) - set(P)
m = 100000000
ans = 0
for i in l:
    if abs(i-X) < m:
        ans = i
        m =abs(i - X)
print(ans)
x, n = map(int, input().split())
p = set(list(map(int, input().split())))

ans = 0

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

print(ans)
x,n=map(int,input().split())
if n!=0:
 s=set(list(map(int,input().split())))
else:
 s=[]
diff=10**18
ans=10**18
for i in range(-10000,10000):
 if i in s:
   continue
 else:
   if abs(x-i)<diff:
     ans=i
     diff=abs(x-i)
print(ans)
import io,sys
def main():
    x,n = map(int,sys.stdin.readline().rstrip().split())
    p = list(map(int,sys.stdin.readline().rstrip().split()))

    x_pos = x
    x_neg = x
    while True:
        if x_neg not in p:
            print(x_neg)
            sys.exit()
        if x_pos not in p:
            print(x_pos)
            sys.exit()
        
        x_pos+=1
        x_neg-=1
main()
x, n = map(int, input().split())
p = set(map(int, input().split()))

ans = 1000
for i in range(102):
    if i not in p:
        ans = min(ans, abs(x - i))
print(x + ans if x - ans in p else x - ans)
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

def calc(X, N, p):
    k = 0
    while True:
        if not X - k in p:
            return X - k
        elif not X + k in p:
            return X + k
        k += 1
    

(X, N) = tuple([int(s) for s in input().split()])
p = [int(s) for s in input().split()]
print(calc(X, N, p))
import itertools
X,N = map(int,input().split())

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

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

L = sorted([abs(X-p) for p in P])
if 0 not in L :
    print(X)
    exit()

DL = list(set([x for x in L if L.count(x) > 1]))

ans_abs = 1
for i,x in enumerate(DL) :
    if x == i+1 :
        ans_abs += 1
    else :
        break

if X-ans_abs in P :
    print(X+ans_abs)
else :
    print(X-ans_abs)
x,n=map(int,input().split())
l=list(map(int,input().split()))
ans=200
for i in range(-200,200):
  if (i not in l and abs(x-i)<abs(x-ans)):
    ans=i
print(ans)
x, n = [int(k) for k in input().split()]

try:
    p = [None if k is None else int(k) for k in input().split()]
except:
    p = []
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
# -*- coding:utf-8 -*-

def solve():
    X, N = list(map(int, input().split()))
    Ps = list(map(int, input().split()))

    if N == 0:
        print(X)
        return

    setP = set(Ps)

    ans = float("inf")
    for x in range(0, 102):
        if not x in setP:
            if abs(X-ans) > abs(X-x):
                ans = x

    print(ans)


if __name__ == "__main__":
    solve()
# C - Forbidden List
def main():
    X, _, *P = map(int, open(0).read().split())
    ans = min(set(range(-1, 102)) - set(P), key=lambda x: abs(X - x))
    print(ans)


if __name__ == "__main__":
    main()
x,n,*p=map(int,open(i:=0).read().split())
while x in p:x+=(-1)**i*i;i+=1
print(x)
# coding: utf-8
# Your code here!

import numpy as np

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

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

m = np.array(list(range(-200,400)))
m = (m-x)**2
for i in (np.argsort(m)-200):
    if p.count(i) == 0:
        print(i)
        break
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


x,n=MAP()
if n==0:
    print(x)
    exit()
a=LI()
l=-1;r=-1
for i in range(101):
    if x-i not in a:
        l=x-i
        break
for i in range(101):
    if x+i not in a:
        r=x+i
        break
if abs(r-x)>=abs(l-x):
    print(l)
else:
    print(r)
#!/usr/bin/env python3
x, n = map(int, input().split())
p = sorted(map(int, input().split()))
ok = [True] * 300
for y in p:
    ok[y + 150] = False
for i in range(150):
    if ok[x - i + 150]:
        print(x - i)
        exit()
    if ok[x + i + 150]:
        print(x + i)
        exit()
X,N = map(int,input().split())

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

count = 0

flg = False

lis=[]

result=0

while True:
    
    up = X+count
    
    down = X-count
    
    if p.count(down) ==0:
        lis.append(down)
        flg = True
    
    if p.count(up)==0:
        lis.append(up)
        flg = True
        
    
    if flg ==True:
        break
    else:
        count+=1
        

lis.sort()

print(lis[0])
X, N = map(int, input().split())
p = list(map(int, input().split()))
for i in range(N+1):
    for j in [-1, 1]:
        ans = X + j * i
        if p.count(ans) == 0:
            print(ans)
            exit(0)