peterverebics/CodeNet_Python_118 huggingface dataset:
X, N = map(int, input().split())
p = list(map(int, input().split()))
k = 0
ans = 0
c = True

while c:
    if (X - k) not in p:
        ans = X -  k
        c = False
        break
    elif (X + k) not in p:
        ans = X + k
        c = False
        break
    else:
        k += 1
        
print(ans)
x,n = map(int,input().split())
p = list(map(int,input().split()))
tmp = []
for i in range(-101,102):
    tmp.append(i)

if n == 0:
    print(x)
else:
    for i in p:
        tmp.remove(i)
    
    ans = []
    for i in tmp:
        a = abs(x-i)
        ans.append(a)
 
    b = min(ans)
    
    c = x+b
    d = x-b
 
    if c and d in tmp:
        print(d)
    elif c in tmp:
        print(c)
    elif d in tmp:
        print(d)
X, N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

for i in range(102):
    if p.count(X-i) == 0:
        print(X-i)
        break
    if p.count(X+i) == 0:
        print(X+i)
        break
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    x, n = map(int, input().split())
    if n >= 1:
        p_set = set(map(int, input().split()))
    else:
        p_set = set()

    print(f(x, p_set))


def f(x, p_set):
    for i in range(101):
        if (x - i) not in p_set:
            return x - i
        elif (x + i) not in p_set:
            return x + i


if __name__ == '__main__':
    main()
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X, N = lr()
P = set(lr())
flag = True
answer = X
while answer in P:
    if flag:
        diff = abs(X - answer)
        answer = X - diff - 1
        flag = False
    else:
        diff = abs(X - answer)
        answer = X + diff
        flag = True

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

for i in range(101):
    sub = x - i
    if sub not in ps:
        print(sub)
        break

    add = x + i
    if add not in ps:
        print(add)
        break
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = set(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 = map(int,input().split())
p_l = list(map(int,input().split()))

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

for i in range(1,100):
    if (x - i) not in p_l:
        print(x-i)
        break
    elif (x + i) not in p_l:
        print(x+i)
        break
stand = []
emp = [100]
ans = []

line = input().split()
x = int(line[0])
if int(line[1]) == 0:
  ans = x
  
elif int(line[1]) != 0:
  line2 = input().split()
  for i in range(-100,201):
    stand.append(int(i))
    
  for i in line2:
    if int(i) in stand:
      stand.remove(int(i))
  for i in stand:
    candi = abs(x - i)
    if candi < emp[0]:
      emp[0] = candi
      ans = i

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

candidates= {}
for i in range(203):
    a = x-101+i
    candidates[a] = abs(x-a)

for p in p_list:
    del candidates[p]
    
min_diff = None
ans = []
for k, v in sorted(candidates.items(), key=lambda x:x[1]):
    if min_diff is None:
        min_diff = v
        ans.append(k)
    elif min_diff == v:
        ans.append(k)
    else:
        break
print(min(ans))
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))

X_max = X
X_min = X

while True:
    if N == 0 or (X in p) == False:
        print(X)
        break
        break
    X_max += 1
    X_min -= 1
    if (X_min in p) == False:
        print(X_min)
        break
        break
    if (X_max in p) == False:
        print(X_max)
        break
        break
x,n = list(map(int,input().split()))
p = list(map(int,input().split()))

ans=1000
for i in range(-105,102):
    if i in p:
        continue
    if abs(x-ans)>abs(i-x):
        ans=i
print(ans)
X,N = [int(_n) for _n in input().split()]
P = [int(_n) for _n in input().split()]
res = 0
for i in range(102):
    if i in P:
        continue
    if abs(X - i) < abs(X - res):
        res = i
print(res)
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
	print(x)
	exit(0)
if x in p:
	a,b = 0,0
	for i in range(1,102):
		if x - i in p:
			continue
		else:
			a = x - i
			break
	for j in range(1,102):
		if x + j in p:
			continue
		else:
			b = x + j
			break
	if a < 0:
		print(b)
	elif b > 101:
		print(a)
	elif abs(x-a) <= abs(x-b):
		print(a)
	else:
		print(b)
else:
	print(x)
x, n = map(int, input().split())
p = list(map(int, input().split()))

for i in range(x+1):
    if not(x - i) in p:
        print(x - i)
        exit()
    elif not(x + i) in p:
        print(x + i)
        exit()
print(x)
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    a=list(map(int,input().split()))
    for i in range(n//2+1):
        if not(x-i in a):
            print(x-i)
            exit()
        if not(x+i in a):
            print(x+i)
            exit()
    print(x-1-n//2)
x ,n = map(int,input().split())
p = list(map(int,input().split()))

for i in range(100):
    num = x - i
    if num not in p:
        print(num)
        exit()
    num = x + i
    if num not in p:
        print(num)
        exit()
x,n=map(int,input().split())
p=list(map(int,input().split()))
p=sorted(p)
c=0
z=0
a=[]
for i in range(n):
    a.append(p[i]-x)
for i in range(100):
    if a.count(-i)==0:
        z=-c
        break
    elif a.count(i)==0:
        z=c
        break
    else:
        c+=1
print(x+z)
X,N=map(int, input().split())
try: 
    p=list(map(int, input().split()))
except:
    print(X)
    exit(0)
if X not in p:
    print(X)
    exit(0)
c=1
while 1:
    if X-c not in p:
        print(X-c)
        exit(0)
    if X+c not in p:
        print(X+c)
        exit(0)
    c+=1
x,n=map(int,input().split())

if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    min=1000000000000000
    ans=0
    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())
Ps =  set(map(int, input().split()))
for i in range(N+1):
    if (X-i) not in Ps:
        print(X-i)
        exit()
    elif (X+i) not in Ps:
        print(X+i)
        exit()
x, n = map(int, input().split())

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    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()))

check = x
tansaku = 1
count = 0
while True:
    count += 1
    if not(check in p_list):
        print(check)
        exit()
    
    check -= tansaku
    tansaku = -tansaku
    if tansaku <0:
        tansaku -= 1
    else:
        tansaku += 1
    if count >= 500:
        exit()
X,N=map(int,input().split())
if N==0:
    print(X)
else:
    a = list(map(int,input().split()))
    res = 10**9
    mi = 10**9
    for val in range(200,-100,-1):
        if val not in a:
            tmp = abs(X-val)
            if res >= tmp:
                res = tmp
                mi = val
    print(mi)
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 = input().split()
X,N = int(X),int(N)

P = input().split()
P = [int(c) for c in P]

i = X
j = X

if len(P) == 0:
    print(X)    
elif X  not in P:
    print(X)
else:
    while i < 101:
        i += 1
        if i not in P:
            break
    while j > 0:
        j -= 1
        if j not in P:
            break
    
    if i - X >= X - j:
        print(j)
    else:
        print(i)
X,N = map(int,input().split())
 
p = list(map(int,input().split()))
 
import sys
for i in range(102):
 
    if X-i not in p:
        print (X-i)
        sys.exit()
    elif X+i not in p:
        print (X+i)
        sys.exit()
x, n = map(int, input().split())
s = list(map(int, input().split()))

for i in range(n//2 +2):
    if x-i not in s:
        print(x-i)
        exit(0)
    if x+i not in s:
        print(x+i)
        exit(0)
X,N = map(int, input().split())
P = list(map(int, input().split()))

table = [0] * 102
ans = X
dist = 102

for p in P:
  table[p] = 1

for i in range(102):
  if table[i] != 0:
    continue
  if abs(i - X) < dist:
    ans = i
    dist = abs(i - X)
  elif abs(i - X) == dist:
    ans = min(i, ans)

print(str(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()
    if x+i not in p:
        print(x+i)
        exit()
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
    
P = set(map(int, input().split()))

d_min = 1000
ans = 1000
for num in range(-1, 102):
    if num in P:
        continue
    
    d = abs(x-num)
    if d < d_min:
        d_min = d
        ans = num

print(ans)
x, n = map(int, input().split())
p = [int(s) for s in input().split()]

min_val = 101
for i in range(102):
    if i not in p:
        if abs(i - x) < min_val:
            min_val = abs(i - x)
            ans = i
print(ans)
import sys

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

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

sub, up = x, x

while True:
  if sub not in p:
    print(sub)
    sys.exit()
  elif up not in p:
    print(up)
    sys.exit()
  sub -= 1
  up += 1
import bisect

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

Pst = set(Ps)

ab = 200
tmp = 200
rlt = -1
for i in range(102):
  if i in Pst:
    continue
  else:
    tmp = abs(i-X)
    if ab > tmp:
      ab = tmp
      rlt = i
      
print(rlt)
x,n = map(int,input().split())
p = set([int(x) for x in input().split()])

mn = 10**10
ans_li = []

for i in range(-200,201):
    if i not in p and abs(x - i) <= mn:
        ans_li.append(i)
        mn = abs(x - i)

for aa in ans_li:
    if abs(aa - x) == mn:
        print(aa)
        break
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

x, n = map(int, input().split())
p = [int(item) for item in input().split()]
seen = set(p)

ans = None 
diff = 200
for val in range(200, -200, -1):
    if val not in seen:
        if abs(val - x) <= diff:
            ans = val
            diff = abs(val - x)

print(ans)
X, N = map(int, input().split())
if N:
    p = list(map(int, input().split()))
    for i in range(N // 2 + 3):
        if X - i not in p:
            print(X - i)
            break
        if X + i not in p:
            print(X + i)
            break
else:
    print(X)
# -*- coding: utf-8 -*-
import sys

X,N = list(map(int, input().rstrip().split()))
p_list = list(map(int, input().rstrip().split()))
#-----

p_set = set(p_list)
delta = 0

while True:
    for d in [-delta, delta]:
        n = X + d
        
        if n in p_set:
            continue
        else:
            print(n)
            sys.exit()
    
    delta += 1
x,n = map(int,input().split())
p_L = list(map(int,input().split()))
p_L = set(p_L)
sa = 101
for i in range(0,200):
    if i not in p_L:
        if sa > min(sa,abs(i-x)):
            sa = abs(x-i)
            ans = i

print(ans)
X,N=map(int,input().split())
P=set(map(int,input().split()))
l=[0]+[(1+i//2)*(-1 if i%2==0 else 1) for i in range(101)]
for i in l:
    if X+i not in P:
        print(X+i)
        break
x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))
''''atcoder beginner contest-170'''

import math
from collections import defaultdict
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C'''
x,n=rm()
l=True
try:
    a=rl()
except:
    a=[]
b=defaultdict(int)
for i in a:
    b[i]=1
mini=math.inf
value=-1
for j in range(-101,201):
    if b[j]!=1:
        if abs(x-j)<mini:
            mini=abs(x-j)
            value=j
print(value)
X,N = map(int,input().split())
P = set(list(map(int,input().split())))
if X not in P:
    print(X)
    exit()
i = 1
while 1:
    if X-i not in P:
        print(X-i)
        exit()
    if X+i not in P:
        print(X+i)
        exit()
    i += 1
x, n = map(int, input().split())
q = list(map(int, input().split()))
p = []
for i in range(102):
    if not i in q:
        p.append(i)
l = []
for i in p:
    l.append(abs(i - x))
print(p[l.index(min(l))])
x, n = map(int,input().split())
P = list(map(int,input().split()))
Q = []
ans = 100
for i in range(-100,101):
    if i+1 in P:continue
    else:
        Q.append(i+1)
for j in Q:
    d = abs(j - x)
    ans = min(d, ans)

l = x -ans
m = x + ans
if l in Q:
    print(l)
else:
    print(m)
X, N = map(int, input().split())
P = sorted(list(map(int, input().split())))

res, diff = 0, float("inf")
for i in range(0, 110):
    if i in P:
        continue
    if diff > abs(X - i):
        res = i
        diff = abs(X - i)

print(res)
def main():
    X,N = map(int, input().split())
    l = [int(x) for x in input().split()]
    
    ans=0
    if N == 0:
        ans = X
    
    for i in range(100000):
        if not (X-i in l):
            ans=X-i
            break
        elif not(X+i in l):
            ans=X+i
            break
    print(ans)
main()
X,N = map(int,input().split())

if N == 0:
  print(X)
elif N == 100:
  if X > 50:  
    print(101)
  else:
    print(0)
else:
  List = list(map(int,input().split()))
  List.sort()

  c = 10 ** 10
  ans = 1000

  for i in range(-100,200):
    if not i in List:
      if abs(i - X) < c:
        c = abs(i-X)
        ans = i
      
  print(int(ans))
import sys
input = sys.stdin.readline

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


l = x
h = x

while True:
    if l not in p:
        break
    else:
        l -= 1

while True:
    if h not in p:
        break
    else:
        h += 1

if (x - l) <= (h - x):
    print(l)
else:
    print(h)
x,n=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 numpy as np
def getNearestValue(Q, num):
    idx = np.abs(np.asarray(Q) - num).argmin()
    return Q[idx]

XN = list(map(int,input().split()))
X = XN[0]
N = XN[1]
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    Q = list(range(-100,200,1))
    for i in range(0,N):
        Q.remove(P[i])
    print(getNearestValue(Q,X))
X,N = map(int,input().split())
p = list(map(int,input().split()))

i = 0
j = 0
flag = 0
while True:
    if(X - i in p):
        i += 1
    else:
        flag = 1
        break
    if(X + j in p):
        j += 1
    else:
        flag = 2
        break
if(flag == 1):
    print(X - i)
elif(flag == 2):
    print(X + j)
import numpy as np

a = input()
a, b = a.split()
a = int(a)
if int(b) == 0:
  print(a)
  exit()
n = input()
n = [int(i) for i in n.split()]
li = list(range(-250, 250))
for i in n:
  li.remove(i)
mini = [np.inf, 0]
for i in li:
  if abs(i - a) == mini[0]:
    if i < mini[1]:
      mini = [abs(i - a), i]
  elif abs(i - a) < mini[0]:
    mini = [abs(i - a), i]
print(mini[1])
X, N = map(int, input().split())
if N != 0:
  p = set(map(int, input().split()))
  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:
    print(X - i - 1)
else:
  print(X)
x, n = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p_l = list(map(int, input().split()))
    p_x_l = [ x-i for i in p_l ]
    for i in range(101):
        if i not in p_x_l:
            print(x-i)
            break
        if -i not in p_x_l:
            print(x+i)
            break
X,N=map(int,input().split())
p=list(map(int,input().split()))
i=0
j=0
while X+i in p:
    i+=1
while X-j in p:
    j+=1
if i>j:
    print(X-j)
elif i<j:
    print(X+i)
else:
    print(min([X+i,X-j]))
X, N = map(int, input().split())
P = list(map(int, input().split()))

if not X in P:
    print(X)
else:
    for i in range(100):
        if not X-i in P: 
            tmp = True
            break
        elif not X+i in P: 
            tmp = False
            break
    print(X-i if tmp else X+i)
X,N=map(int, input().split())
lis = list(map(int, input().split()))
p=list(range(102))
# print(p)
for i in lis:
    p.remove(i)
# print(p)
d=10000
m=10000
for i in p:
    if d > abs(X-i):
        d = abs(X-i)
        m = i
print(m)
X, N = map(int, input().split())
p = list(map(int, input().split()))

for i in range(X+1):
    for s in [-1, 1]:
        a = X + s * i
        if p.count(a) == 0:
            print(a)
            exit()
x, n = map(int, input().split())
P = set(list(map(int, input().split())))
notP = set(list(range(-1, 102))) - P
#print(notP)

min_dif = 10000
ans = 10000
for num in list(notP):
    dif = abs(x - num)
    if dif < min_dif:
        min_dif = dif
        ans = num
    elif dif == min_dif and num < ans:
        min_dif = dif
        ans = num
print(ans)
ma = lambda :map(int,input().split())
x,n = ma()
P = list(ma())
import collections
co = collections.Counter(P)
mi = -1
ab = 10**9
for i in range(-1,102):
    if abs(x-i) <ab:
        if co[i] >0:
            continue
        ab = abs(x-i)
        mi = i
print(mi)
X,N = map(int,input().split())
P = list(map(int,input().split()))

a = list(range(102))
for i in range(N):
    a[P[i]] = -2
m = 102
for i in range(102):
    if m > (abs(X - a[i])):
        m = (abs(X - a[i]))
        ans = a[i]
print(ans)
x, n = map(int, input().split())

ret = 0
diff = 10 ** 9

if n == 0:
    s = input()
    print(x)
    exit()
else:
    p = set(list(map(int, input().split())))
    for i in range(102):
        if i in p:
            continue
        else:
            tmp_d = abs(x - i)
            if diff > tmp_d:
                ret = i
                diff = tmp_d

print(ret)
M,N = map(int,input().rstrip().split(" "))
if N != 0:
    A = set(map(int,input().rstrip().split(" ")))
    ans = -100
    sa = 10 ** 5
    for i in range(-1,102):
        if not i in A:
            if sa > abs(M - i):
                sa = abs(M - i)
                ans = i
    print(ans)
else:
    print(M)
X, N = list(map(int, input().split()))
if N > 0:
    P = list(map(int, input().split()))
    l = X
    h = X
    while True:
        if l not in P:
            print(l)
            break
        if h not in P:
            print(h)
            break
        l -= 1
        h += 1
else:
    input()
    print(X)
x, n = map(int, input().split())
p = list(map(int,input().split()))
p.sort()
s = x
d = 1
while s in p:
    s = s - d
    d = int((abs(d)+1)*d/abs(d)*(-1))
print(s)
X,N = map(int,input().split())
P = list(map(int,input().split()))
if P == []:
  print(X)
  exit()
for n in range(101):
  if X - n not in P:
    ans = X - n
    break
  if X + n not in P:
    ans = X + n
    break

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

diff = 0
while True:
    if X - diff not in P:
        print(X - diff)
        break
    elif X + diff not in P:
        print(X + diff)
        break
    else:
        diff += 1
x, n = map(int, input().split())
p = list(map(int, input().split()))
y = None
if x in p:
    for i in range(102):
        if i in p:
            continue
        if y is None or abs(x - i) < y:
            y = abs(x - i)
            ans = i
else:
    ans = x
print(ans)
x,n = map(int, input().split())
p = list(map(int, input().split()))
ab = min(abs(101 - x),abs(x))
if abs(101 - x) >= abs(x):
    answer = 0
else:
    answer = 101
for i in range(1,101):
    if i in p:
        continue
    else:
        if ab > abs(x - i):
            ab = abs(x - i)
            answer = i
        elif ab == abs(x-i) and answer > i:
            answer = i
print(answer)
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

arr = [0] * 1000
for i in p:
    arr[i] = 1

ans1 = 0
for i in range(x, -1, -1):
    if arr[i] == 0:
        ans1 = i
        break

# print(arr)

ans2 = 0
for i in range(x, 102):
    if arr[i] == 0:
        ans2 = i
        break

if abs(ans1 - x) <= abs(x - ans2):
    print(ans1)
else:
    print(ans2)
x,n=map(int,input().split())
l=list(map(int,input().split()))
y=x
while True:
	if x not in l:
		print(x)
		break
	if y not in l:
		print(y)
		break
	x-=1
	y+=1
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
sa = 1000
ans = 0
for i in l-p:
    if sa > abs(x-i):
        sa = abs(x-i)
        ans = i
print(ans)
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))

ans = float('inf')
cnt = 0
while ans == float('inf'):
  ans_plus = X + cnt
  ans_minus = X - cnt
  if not ans_plus in P:
    ans = ans_plus
  if not ans_minus in P:
    ans = min(ans, ans_minus)
  cnt += 1

print(ans)
numbers = [int(i) for i in input().split()]
sequences = [int(i) for i in input().split()]
x = numbers[0]
y = numbers[0]
a = True
if numbers[0] not in sequences:
    print(numbers[0])
    a = False
while a:
    x += 1
    y -= 1
    if y not in sequences:
        print(y)
        break
    elif x not in sequences:
        print(x)
        break
X,N = map(int, input().split())
P = list(map(int, input().split()))
maxP = 0 if P == [] else max(P)
le = 1000
for k in reversed(range(X+1)):
  if k not in P:
    le = X-k
    ans = k
    break
# for k in range(X,maxP+1):
for k in range(X,102):
  if k not in P:
    if le > k-X:
      ans = k
      break
print(ans)
def resolve():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        return
    A = set(map(int, input().split()))
    dic = {}
    for i in range(-10, 110):
        if i not in A:
            dic[i] = abs(X-i)

    sorted_A = sorted(dic.items(), key=lambda x:(x[1], x[0]))
    print(sorted_A[0][0])

if __name__ == "__main__":
    resolve()
X, N = map(int, input().split())#
p = map(int, input().split())
p = list(p)
tmp = X
Y = X
tmp1 = 0
tmp2 = 0
if X not in p:
  tmp1 = X
for i in range(N):
  if X not in p:
    tmp1 = X
  else:
    X = X + 1
  if Y not in p:
    tmp2 = Y
  else:
    Y = Y - 1
if abs(tmp1 - tmp) >= abs(tmp2 - tmp):
  print(tmp2)
else:
  print(tmp1)
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = float("inf")
for i in range(-101,201):
    if i not in p:
        ans = min(ans,abs(x-i))
if x - ans not in p:
    print(x-ans)
else:
    print(x+ans)
X,N=list(map(int, input().split(' ')))
if N>0:
    p=list(map(int, input().split(' ')))
else:
    p=[]
A=0
A2=400
A3=0
for i in range(0,200):
    if i in p:
        v=0
    else:
        A=abs(i-X)
        if A<A2:
            A2=A
            A3=i
        else:
            print(A3)
            exit()
def main():
    X, N = map(int, input().split())
    P = set(list(map(int, input().split())))

    d, v = X, 0
    for i in range(102):
        if i in P:
            continue
        if abs(i - X) < d:
            d = abs(i - X)
            v = i
    return v


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

p=list(map(int,input().split()))
for i in range(x,110):
  if 2*x-i not in p:
    print(2*x-i)
    sys.exit()
  if i not in p:
    print(i)
    sys.exit()
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

X, N = ri_()
p = ri_()
d = 1000
ans = 1000
for i in range(-500, 501):
    f = 1
    for pi in p:
        if i == pi:
            f = 0
    if f == 1 and d > abs(X - i):
        d = abs(X - i)
        ans = i
print(ans)
X,N = map(int,input().split())
if(N==0):
    print(X)
else:
    P = [int(i) for i in input().split()]
    A = []
    for i in range(-100,201):
        if not i in P:
            A.append([abs(X-i),i])

    A.sort()
    s = A[0][0]
    B = [[i,j] for i,j in A if i==s]
    B.sort(key = lambda x:x[1])
    print(B[0][1])