peterverebics/CodeNet_Python_118 huggingface dataset:
num = list(map(int, input().split()))
if num[1] != 0:
    arr = list(map(int, input().split()))
    arr.sort()
    l_num = arr[0]
    l_diff = 10000
    for i in range(arr[0]-1, arr[-1]+2):
        if abs(num[0]-i) < l_diff and i not in arr:
            #print(i, num[0], l_num, abs(i-num[0]))
            l_num = i
            l_diff = abs(num[0]-i)
    print(l_num)
else:
    print(num[0])
##C
X,N = map(int,input().split())
P = list(map(int,input().split()))
i=0
j = 0
while X+i<=101:
    if X+i not in P:
        ans1 = X+i
        break
    i += 1
while X-j>=-1:
    if X-j not in P:
        ans2 = X-j
        break
    j += 1
if ans1-X>=X-ans2:
    print(ans2)
else:
    print(ans1)
X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  q = list(map(int,input().split()))
  q = list(set(q))
  p = [i for i in range(-2 , 102)]
  for i in range(len(q)):
    p.remove(q[i])

  S = 103
  for i in range(len(p)):
    if abs(X - p[i]) < S :
      ans = p[i]
      S = X - ans
    elif abs(X - p[i]) == S :
      if p[i] < ans :
        ans = p[i]
  print(ans)
X,N=map(int, input().split())
NL=list(map(int, input().split()))
BL=[i for i in range(-1,102)]

for i in NL:
    BL.remove(i)

ANS=1000
out=1000
for i in BL:
    temp=abs(X-i)
    if ANS>temp:
        ANS=temp
        out=i
print(out)
X,N=map(int,input().split())
if N==0:
    input()
    print(X)
    exit(0)
xn=list(map(int,input().split()))

a=[(abs(x-X),x) for x in xn]

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

ans = 0
res = 10**9
for i in range(x-100, x+101):
    if i in p:
        continue
    diff = abs(x-i)
    if diff < res:
        ans = i
        res = diff
print(ans)
X, N = map(int,input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))
pset = set(p)

for i in range(200):
  MIN = X-i
  MAX = X+i
  if MIN not in pset:
    print(MIN)
    exit()
  elif MAX not in pset:
    print(MAX)
    exit()
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x,n = mi()
p =li()

# small side
xs = x
while 1:
    if xs not in p:
        break
    xs -= 1

# large side
xl = x
while 1:
    if xl not in p:
        break
    xl += 1

if x-xs > xl - x:
    print(xl)
else:
    print(xs)
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    x, n = map(int, readline().split())
    p = list(map(int, readline().split()))
    check = float('inf')
    ans = 0
    for i in range(1000):
        if i not in p:
            if check > abs(x - i):
                ans = i
                check = abs(x - i)
    print(ans)


if __name__ == '__main__':
    main()
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)
    exit()
  elif x+i not in p:
    print(x+i)
    exit()
  i += 1
X,N = map(int,input().split())
if N>0:
  p=list(map(int,input().split()))
  for d in range(0,101):
    if (X-d) not in p:
      print(X-d)
      break
    elif (X+d) not in p:
      print(X+d)
      break
else:print(X)
x,n = input().split()
x=int(x)
list=input().split()
diff = 200
for i in range(-1, 102):
    if str(i) not in list and abs(i-x) < diff:
        diff = abs(i-x)
        ans = i
print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
for i in range(100):
    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())
P = list(map(int, input().split()))
ans = -1
mi = 1000
for i in range(102):
    if i in P:
        continue
    if abs(i-X) < mi:
        mi = abs(i-X)
        ans = i
print(ans)
X, N = map(int, input().split())
if N==0: print(X);exit()
p = list(map(int, input().split()))
count = 0
while True:
  if X - count not in p:
    print(X-count)
    exit()
  if X + count not in p:
    print(X+count)
    exit()
  count += 1
import numpy as np

def ForbiddenList():

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

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

    if len(NumB) != 0:
        result = list(range(min(NumB)-1, max(NumB)+2, 1))

        for data in NumB:
            result.remove(data)

        idx = np.abs(np.asarray(result) - NumA[0]).argmin()

        print(result[idx])

    else:
        print(NumA[0])
    

if __name__ == '__main__':
    ForbiddenList()
x, n = map(int, input().split())
a = set(map(int, input().split()))
print(min((i for i in range(102) if i not in a), key=lambda y:abs(x-y)))
def solve():
    x,n=map(int,input().split())
    if not n==0:
        p=list(map(int,input().split()))
    else:
        print(x)
        return
    
    for i in range(0,100):
        
        if not (x-i) in p:
            print(x-i)
            return
        
        if not (x+i) in p:
            print(x+i)
            return
        
        
solve()
x,n = map(int, input().split())
p = list(map(int, input().split()))

ans = -1
i = 1

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

while ans == -1:
    temp = x -i
    if temp not in p:
        ans = temp
        break
    temp = x + i
    if temp not in p:
        ans = temp
        break
    i += 1

print(ans)
X, N = map(int, input().split())
if N !=0:
  A = list(map(int, input().split()))
  A.sort()
MIN = 1000
if N ==0:
  print(X)
elif not X in A:
  print(X)
else:
  for i in range(X*10):
    N = abs(X - i)
    if not i in A:
      if MIN > N:
        Z = i
        MIN = N
  print(Z)
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

x,n = MI()
mylist = tuple(MI())

num = 0
while True:
    if not(x - num in mylist):
        print(x- num)
        sys.exit()
    if not(x + num in mylist):
        print(x+ num)
        sys.exit()
    num += 1
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    x, n= map(int, input().split())
    if n == 0:
        print(x)
        return
    P=[]
    P = list(map(int, input().split()))
    
    for i in range(100):
        a = x-i
        b = x+i
        if a not in P:
            print(a)
            return
        elif b not in P:
            print(b)
            return
    


main()
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  plist=list(map(int,input().split()))
  if x not in plist:
    print(x)
  else:
    
    for i in range(100000):
      if x-i-1 not in plist:
        print(x-i-1)
        break
      elif x+i+1 not in plist and x-i-1 in plist:
        print(x+i+1)
        break
X, N = map(int, input().split())
p = list(map(int, input().split()))

d = {i: 1 for i in p}
idx = X
while True:
    if d.get(idx) is None:
        ans_plus = idx
        break
    else:
        idx += 1

idx = X
while True:
    if d.get(idx) is None:
        ans_minus = idx
        break
    else:
        idx -= 1

if abs(X - ans_plus) < abs(X - ans_minus):
    print(ans_plus)
else:
    print(ans_minus)
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = []
sortlist = []
if n == 0:
    print(x)
else:
    p.sort()
    p1 = p[0]
    pn = p[n-1]
    new = [i for i in range(0, 102)]
    nolist = set(new) ^ set(p)
    nolist = list(nolist)

    for i in range(0, len(nolist)):
        d = abs(nolist[i] - x)
        sortlist.append(d)

        k = sortlist.index(min(sortlist))
    print(nolist[k])
x,n=map(int,input().split())
l=list(map(int,input().split()))
num=[]
for i in range(-100,102):
    num.append(i)
for i in l:
    num.remove(i)
dif=101
ans=[]
for i in num:
    if dif>abs(i-x):
        dif=abs(i-x)
        ans=[i]
    elif dif==abs(i-x):
        ans.append(i)
print(min(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)
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)
        exit()
    if not (x + i) in p:
        print(x+i)
        exit()
    i += 1
x, n = [int(i) for i in input().split(' ')]

if n:
    p = [int(i) for i in input().split(' ')]
    if x in p:
        for i in range(1, 101):
            if not x - i in p:
                print(x - i)
                exit()
            elif not x + i in p:
                print(x + i)
                exit()
    else:
        print(x)
else:
    print(x)
x, n = map(int, input().split())
p = list(map(int, input().split()))

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


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())
if(N == 0):
    print(str(X))
    exit()
p = list(map(int,input().split()))
p = sorted(p)
tmp = 200
for i in range(102):
    if(i in p):
        pass
    else:
        tmp2 = abs(X-i)
        if(tmp2 < tmp):
            tmp = tmp2
            ans = i
        elif(tmp2 == tmp):
            pass
print(str(ans))
x, len_arr = map(int, input().split())

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

arr = set(map(int, input().split()))

for i in range(0, 100):
    if x - i not in arr:
        print(x - i)
        exit(0)
    if x + i not in arr:
        print(x + i)
        exit(0)
def solve(x, n, p):
    S = set(p)
    for d in range(n+1):
        for y in [x-d, x+d]:
            if not y in S:
                return y

x, n = map(int, input().split())
p = list(map(int, input().split()))
print(solve(x, n, p))
x, n = map(int, input().split())
p = set(map(int, input().split()))
mi = 1000
for i in range(102):
    if i in p:
        continue
    if abs(i-x)<mi:
        mi = abs(i-x)
        ans = i
print(ans)
X, N = input().split()
X = int(X)
N = int(N)
searchA = X
searchB = X
max = 100
z = X

if N != 0:
  A = list(map(int, input().split()))
  for val in range(max):
    if searchA in A:
      if searchA > -1:
        searchA -= 1
      else:
        continue
    else:
      z = searchA
      break
    if searchB in A:
      if searchB < 102:
        searchB += 1
      else:
        continue
    else:
      z = searchB
      break
    
print(z)
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    L = list(map(int,input().split()))
    for i in range(100):
        if X - i not in L:
            print(X-i)
            break
        elif X + i not in L:
            print(X+i)
            break
x,n = map(int,input().split())
pl = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()
for i in range(100):
  if not x-i in pl:
    print(x-i)
    exit()
  if not x+i in pl:
    print(x+i)
    exit()
X,N=map(int,input().split())
alist = list(map(int, input().split()))
for a in range(X+1):
    for b in [-1,+1]:
        c = X + a * b
        if alist.count(c) == 0:
            print(c)
            exit(0)
# itne me hi thakk gaye?
x, n = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
if x in arr:
    ans = 10**9
    diff = 10**9
    for i in range(0, 102):
        if i not in arr:
            if(abs(x - i) < diff):
                diff = abs(x-i)
                ans = i
    print(ans)
else :
    print(x)
import numpy as np

X, N = (int(x) for x in input().split())
if N == 0:
    print(X)
else:
    p = np.array([int(x) for x in input().split()])
    x_arange = set(np.arange(-100, 101))
    p_x = set(np.array(p - X))
    sub_list = list(x_arange - p_x)
    sub_abs_list = np.abs(np.array(sub_list))

    min_sub = min(sub_abs_list)
    if (X - min_sub) not in p:
        print(X - min_sub)
    else:
        print(X + min_sub)
X,N = map(int,input().split())

min = 100

if N !=0:
  Plist = list(map(int,input().split()))
  anslist = [i for i in range(102)]
  anslist.append(-1)
  #anslist.remove(0)
  Plist = sorted(Plist)
  #print (anslist)
  for i in range(N):
    anslist.remove(Plist[i])
    temp =100
  for i in range(len(anslist)):
    if min >abs(anslist[i]-X) :
      min = abs(anslist[i]-X)
      temp = anslist[i]
  print (temp)
else :
  print (X)
import sys
x,N=list(map(int, input().split()))
if N==0:
  print(x)
  sys.exit()
p=list(map(int, input().split()))


z=float("inf")
ans_temp=[0,0]
ans=[0,0]

y=[i for i in range(-1,102) if i not in p]

for i in y:
  if z>abs(x-i):
    ans[0]=abs(x-i)
    ans[1]=i
  elif z==abs(x-i):
    ans_temp[0]=abs(x-i)
    ans_temp[1]=i
    if ans_temp[1]<ans[1]:
      ans[1]=ans_temp[1]
  z=abs(x-i)
print(ans[1])
X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(102):
  if i not in p:
    if abs(i-X)<abs(ans-X):
      ans = i
print(ans)
x,n=map(int,input().split())
p=list(map(int,input().split()))
j=0
while(1):
    if((x-j in p)==False):
        print(x-j)
        break
    elif((x+j in p)==False):
        print(x+j)
        break
    j+=1
x, n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    #for i in range(n):
    #    p.append(input().split())
    #print(p)
    #rint(type(p[0]))
    min = 1e9
    ans = 0
    for i in range(102):
        #i = i + 1
        if i in p:
            continue
        sa = abs(x - i)
        #print(sa)
        if min > sa :
            min = sa
            ans = i
if n == 0:
    print(x)
else:
    print(ans)
x,n = map(int, input().split())
if n > 0:
	l = list(map(int,input().split()))
else:
	l = []
tl = []
for i in range(0,102):
	if i not in l:
		tl.append(i)
tlabs = []
for i in tl:
	tlabs.append(abs(x - i))
ans = tl[tlabs.index(min(tlabs))]
print(ans)
# C - Forbidden List
X, N = map(int, input().split()) 
num_list = list(map(int, input().split())) 
for i in range(len(num_list)):
    num_list[i] = num_list[i]-X
for i in range(101):
    if (-i in num_list) is False:
        print(X-i)
        break
    if (i in num_list) is False:
        print(X+i)
        break
#ABC170C ×

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

if n == 0:
    print(x)
    
else:
    _x = x 
    x_ = x
    while True:
        if _x not in p:
            print(_x)
            break
        if x_ not in p:
            print(x_)
            break
        _x -= 1
        x_ += 1
x, n = map(int, input().split())
p = list(map(int, input().split()))

sp = set(p)
ans = -200
for i in range(-100, 102):
    if abs(x-i) <= abs(x-ans) and not i in sp:
        if abs(x-i)==abs(x-ans):
            ans = min(ans, i)
        else:
            ans = i
print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))
xp =x; xm =x
for i in range(n+1):
    if not (xm in p):
        print(xm)
        break
    if not (xp in p):
        print(xp)
        break
    xp += 1
    xm -= 1
x, n = map(int, input().split())

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

n = -1
m = 999
for num in range(-1, 102):
    if num in nums:
        continue
    elif m != min(m, abs(num - x)):
        n = num
        m = min(m, abs(num - x))

print(n)
X ,N = [int(i) for i in input().split()]
N_list = [int(n) for n in input().split()]
count = 0
while(True):
    if not X-count in N_list:
        min_abs = X - count
        break
    elif not X+count in N_list:
        min_abs = X + count
        break
    count += 1
print(min_abs)
from bisect import bisect
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    X, N = map(int, input().split())
    P = list(map(int, input().split()))

    if not N:
        print(X)
        return

    nums = []
    for i in range(min(P) - 1, max(P) + 2):
        if i not in P:
            nums.append(i)
    i = bisect(nums, X)
    if abs(nums[i] - X) < abs(nums[i-1] - X):
        print(nums[i])
    else:
        print(nums[i-1])


main()
def main():
    X, N = map(int, input().split())
    if N != 0:
        A = list(map(int, input().split()))
    else:
        A = []
    min_diff = 1e5
    for i in range(0, 102):
        if i not in A:
            min_diff = min(min_diff, abs(i - X))
    
    for i in range(0, 102):
        if i not in A and abs(i - X) == min_diff:
            print(i)
            return 
  
if __name__ == '__main__':
    main()
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    X, N = map(int, readline().split())
    p = set(map(int, readline().split()))
    pallset = set(range(-1, 102))
    remain = pallset - p
    dist = 200; ans = []
    for i in remain:
        if dist > abs(i-X):
            dist = abs(i-X)
            ans.append((i, dist))
    ans.sort(key=lambda x: x[1])
    print(ans[0][0])

if __name__ == "__main__":
    main()
x,n=map(int,input().split())
p = list(map(int,input().split()))
p.sort()
b = []
for i in range(0,102):
    if not (i in p):
        b.append((i,abs(i-x)))

b.sort(key=lambda x:x[1])
print(b[0][0])
X, N = map(int, input().split())
p_list = [int(i) for i in input().split()]

if N == 0:
    print(X)
elif X not in p_list:
    print(X)
else:
    check_list = []
    for i in range(1, 105+1):
        check_list.append(X-i)
        check_list.append(X+i)

    for el in check_list:
        if el not in p_list:
            break

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

table = [True] * 102
for p in ps:
    table[p] = False
if table[x]:
    print(x)
    exit()

i = 1
while True:
    if table[x - i]:
        print(x - i)
        break
    if table[x + i]:
        print(x + i)
        break
    i += 1
X, N = map(int, input().split())
plist = [int(i) for i in input().split()]

x = 0
hx = -1
while True:
    px = x
    nx = -x
    if X + nx not in plist: 
        hx = nx
        break
    if X + px not in plist:
        hx = px
        break
    x += 1
print(X+hx)
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())
p=list(map(int, input().split()))

i=0

while i<200:
    
    jud=1
    con=x-i

    for j in range(n):

        if con==p[j]:
            jud=0
            break

    if jud==1:
        print(con)
        break

    jud=1
    con=x+i

    for k in range(n):

        if con==p[k]:
            jud=0
            break

    if jud==1:
        print(con)
        break

    i+=1
# coding: utf-8

x, N = map(int,input().split())
if N != 0:
    P = list(map(int,input().split()))
    L = [i for i in range(-1000, 1010)]

    l = list(set(P)^set(L))
    dis = 10**9
    
    for i in range(len(l)):
        dis_ = abs(x-l[i])
        if dis_ < dis:
            ans = l[i]
            dis = dis_
else:
    ans = x


print(ans)
X, N = list(map(int,input().split()))
if N !=0:
  P = list(map(int,input().split()))
  ab = 100
  for i in range(-100,200):
    if i not in P:
      if abs(X-i)<ab:
        ab = abs(X-i)
        ans = i
  print(ans)
else:
  print(X)
X, N = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
# Xは0~101の値になる
result = 0
current = 102
for i in range(102):
    if i not in P:
        if abs(X - i) < current:
            result = i
            current = abs(X - i)
print(result)
X, N = map(int, input().split())
lst = [int(x) for x in input().split()]
if N == 0 or X not in lst:
    print(X)
else:
    i = 1
    while True:
        if X - i not in lst:
            print(X - i)
            exit()
        elif X + i not in lst:
            print(X + i)
            exit()
        i += 1
x, n =map(int, input().split())
p = []
if n != 0:
    p = list(map(int, input().split()))

result = x
if n != 0:
    for i in range(0, 1000):
        if not (x - i) in p:
            print(x - i)
            break
        if not (x + i) in p:
            print(x + i)
            break
else:
    print(x)
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit(0)
inp = list(map(int,input().split()))
a = []
for i in range(-100,113):
  if i not in inp:
    a.append(i)

res = 0
minn = 1e5
for i in a:
  if abs(i-x) < minn:
    minn = abs(i-x)
    res = i
    
print(res)
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) #b_tmpはbとxの差分のリストをさくせい
address = b_tmp.index(min(b_tmp))
print(b[address])
x, n = map(int, input().split())
p = list(map(int, input().split()))

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

for y in range(x+1):
  for b in[-1,1]:
    c=x+y*b
    if a.count(c)==0:
      print(c)
      exit(0)
x,n = map(int, input().split())
p = list(map(int, input().split()))

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

mindiff = 10*10
ans=-1
for i in range(-10,200):
    if i in p:
        continue
    if abs(i - x) < mindiff:
        ans = i
        mindiff = abs(i-x)
print(ans)
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))

    for xi in range(x,102):
        if not xi in p:
            break
        
    for xi2 in range(x,-1,-1):
        if not xi2 in p:
            break

    if xi-x<x-xi2:
        print(xi)
    else:
        print(xi2)
def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))

    nums = [i for i in range(-200, 200)]

    for i in range(N):
        nums.remove(p[i])
        
    min_diff = 1000
    min_index = 1000

    for i in range(len(nums)):
        if abs(X - nums[i]) < min_diff or (abs(X - nums[i]) == min_diff and nums[min_index] > nums[i]):
            min_diff = abs(X-nums[i])
            min_index = i

    print(nums[min_index])


if __name__ == '__main__':
    main()
import sys
X,N=map(int, input().split())
p = list(map(int, input().split()))
a=X
for i in range(0,101):
    if (a-i in p)==False:
        print(a-i)
        sys.exit()
    if (a+i in p)==False:
        print(a+i)
        sys.exit()
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int,input().split())]
ans = 100+100 # inf = x + d + 1
for d in range(100): # [0,100)
    now_diff = abs(ans - x)
    min_x, max_x = x - d, x + d
    if min_x not in P:
        if now_diff > abs(min_x - x): ans = x-d
    elif max_x not in P:
        if now_diff > abs(max_x - x): ans = x+d
print(ans)
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = {i for i in range(-100, 200)}

s = list(l - p)
min_diff = 1000
ans = 1000

for j in range(len(s)):
    diff = abs(s[j] - x)
    if min_diff > diff:
        min_diff = diff
        ans = s[j]

print(ans)
import sys

X,N=map(int,input().split())
if N==0:
	print(X)
	sys.exit()

p=list(map(int,input().split()))
n=[0]*(103)
for i in range(len(p)):
	n[p[i]+1]=1

d_min=1000
for j in range(103):
	if n[j]!=1:
		d=abs((X+1)-j)
		if d_min>d:
			d_min=d
			ans=j-1
print(ans)
X,N = map(int,input().split())
p = set(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())
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    i = 0
    while(1):
        if X-i not in P:
            m = X-i
            break
        i += 1
    for i in range(X-m):
        if X+i not in P:
            m = X+i
            break
    print(m)
X, N = map(int,input().split())
p = list(map(int,input().split()))
result = 0
temp = 10000

for i in range(-100,102):
    if i not in p and temp > abs(X - i):
        temp = abs(X-i)
        result = i
print(result)
X, N = map(int, input().split())
ps = list(map(int, input().split()))
for i in range(101):
    if X - i not in ps:
        print(X-i)
        exit()
    if X + i not in ps:
        print(X+i)
        exit()
import sys
x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
p = [int(x) for x in input().split()]


diff = 0
while(True):
    if not x + diff in p:
        print(x+diff)
        sys.exit()

    if diff < 0:
        diff *= -1
    else:  # 0以上
        diff *= -1
        diff -= 1