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

    for i in range(n):
        if x-i in p:
            if x+i in p:
                a =0
            else:
                print(x+i)
                exit(0) 
        else:
            print(x-i)
            exit(0)
x, n = map(int, input().split())
arr = sorted(list(map(int, input().split())))
mins = 10000
idx = 0
for i in range(1, 101):
    if abs(i-x) < mins and i not in arr:
        mins = abs(i-x)
        idx = i
print(idx)
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==0:
  print(n)
else:
  a.sort()
  if n not in a:
    print(n)
  else:
    cnt=0
    for i in range(101):
      if i in a:
        continue
      elif abs(cnt-n)>abs(i-n):
        cnt=i
    print(cnt)
x,n = map(int,input().split())
if n==0: exit(print(x))
p = list(map(int,input().split()))
p.sort()
if x not in p: exit(print(x))
h=1000
l=1000
for i in range(x,101):
    if i not in p:
        h = i
        break
for i in range(x,0,-1):
    if i not in p:
        l = i
        break
if abs(x-h)>=abs(x-l): print(l)
if abs(x-l)>abs(x-h): print(h)
X,N=map(int,input().split())
P=list(map(int,input().split()))
p=[]
for j in range(X*2):
    if j in P:
        a=0
    else:
        p.append(j)
result=1000
answer=1000
for i in range(X*2-N):
    if abs(X-p[i])<result:
        answer=p[i]
        result=abs(X-p[i])
    elif abs(X-p[i])==result and p[i]<=answer:
        answer=p[i]
print(answer)
x,n=map(int,input().split())

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

  for i in range(100):
    if x-i not in a:
      ans=x-1
      break
    if x+i not in a:
      ans=x+i
      break
    
  print(ans)
def solve(x, ls):
    y = 0
    m = x
    for i in range(1, 102):
        if i in ls:
            continue
        if abs(x - i) < m:
            y = i
            m = abs(x - i)
    return y


def main(istr, ostr):
    x, n = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    result = solve(x, ls)
    print(result, file=ostr)
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = set(map(int, input().split()))

i = 1
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 = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    count = 0
    ans = 0
    while True:
        count +=1
        if X-count not in p:
            ans = X-count
            break
        elif X+count not in p:
            ans = X+count
            break
    print(ans)
x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
#print(x,n)
#print(p)
#print(max(p))
y = 100
ans = n
if n == 0:
  print(x)
else:
  for i in range(0,101):
    if i != x:
      if p.count(i) == 0:
        #print('i=',i,abs(x-i))
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
  print(ans)
X, N = input().split()
p = list(map(int, input().split()))
Z = list(range(0, 101))

q = [i for i in Z if i not in p]
t = []

for i in range(0, len(q)):
    t.append(abs(int(X)-q[i]))

print(q[(t.index(min(t)))])
x, n = map(int, input().split())
p = list(map(int, input().split()))
counter = 1
find = 0
while True:
  ceil = counter / 2 if counter % 2 == 0 else (counter // 2 + 1)
  find = int(ceil * ((-1) ** counter))
  if (x + find) not in p:
    find = x + find
    break
  counter += 1
print(x if n == 0 else find)
X, N = list(map(int, input().split()))
p = set(map(int, input().split()))

dist = 0

if N == 0:
    print(X)
    dist_max = -1
else:
    dist_max = max(abs(max(p) - X), abs(min(p) - X))

while dist <= dist_max:

    if (X - dist in p) and (X + dist in p):
        dist += 1
        continue

    if not (X - dist in p):
        print(X - dist)
        break
    elif not (X + dist in p):
        print(X + dist)
        break
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
ans = 0
dist = 100
for i in range(100):
    i+=1
    if not i in p:
        if abs(x-i)<dist:
            dist = abs(x-i)
            ans = i
print(ans)
import sys
x,n = map(int,input().split())

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

p,f = x-1,x+1
bans = set(map(int,input().split()))
while True:
    if p not in bans:
        print(p)
        break 
    p -= 1
    
    if f not in bans:
        print(f)
        break 
    f += 1
x,n = map(int,input().split())
p = list(map(int,input().split()))
notp = []

for i in range(0,101):
  if i not in p:
    notp.append(i)

for j in range(len(notp)):
  if j != len(notp)-1:
    
    if abs(x-notp[j+1]) >= abs(x-notp[j]):
      print(notp[j])
      break
  else:
    print(notp[j])
    break
x, n = map(int, input().split())
pli = [int(i) for i in input().split()]
ans = 0
for s in range(1, 100):
    if not x in pli:
        ans = x
    elif not x - s in pli and not x + s in pli:
        ans = x - s
        break
    elif x - s in pli and not x + s in pli:
        ans = x + s
        break
print(ans)
x,n = map(int, input().split())

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

for i in range(-100, 101):
    if(not i in p):
        if((abs(x-ans) > abs(x-i)) or(abs(x - ans) == abs(x - i) and i < ans)):
            ans = i

print(ans)
X, N = map(int, input().split())
p_list = [str(e) for e in input().split()]

for i in range(N + 1):
    x = X - i
    y = X + i
    if str(x) in p_list == 0:
        print(x)
        break
    elif str(y) in p_list == 0:
        print(y)
        break
a, b = map(int, input().split())
list2 = set(map(int, input().split()))
list1=list(range(-100,101,1))
result = list(set(list1) - set(list2))
for i in range(110):
    if a-i in result:
        print(a-i)
        exit()
    elif a+i in result:
        print(a+i)
        exit()
X,N = map(int, input().split())
P = list(map(int, input().split()))

if len(P) == 0:
  print(X)
else:
  for i in range(1,101):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue
x,n=map(int,input().split())
try:
  p=list(map(int,input().split()))
except:
  print(x)
  exit()
ans=float('inf')
for i in range(1,101):
  if i not in p:
    ans=min(ans,abs(x-i))
    
    
if x-ans not in p and (x-ans)>=0 and (x-ans)<=x:
  print(x-ans)
  
elif x-ans not in p and (x-ans)<=x:
  print(x+ans)
elif x-ans not in p and (x-ans)>=0:
  print(x-ans)
else:
  print(x+ans)
X,N = map(int,input().split())
p = list(map(int, input().split()))

for i in range(X):
  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())
p = list(map(int,input().split()))
min1=[]
x_min = 100
num_list = list(range(101))
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)
X, N= list(map(int, input().split()))
P = list(map(int, input().split()))
if N == 0:
    print(X)
else:
    for i in range(1, 51):
        try:
            P.index(X - i)
        except Exception:
            print(X - i)
            break

        try:
            P.index(X + i)
        except Exception:
            print(X + i)
            break
x,n=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
np=[i for i in range(0,101) if not i in p]
r=0
for i in np:
    if abs(x-i)<abs(x-r):
        r=i
print(r)
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==0:
  print(n)
else:
  a.sort()
  if n not in a:
    print(n)
  else:
    cnt=0
    for i in range(100):
      if i in a:
        continue
      elif abs(cnt-n)>abs(i-n):
        cnt=i
    print(cnt)
x, n = map(int, input().split())
p = list(map(int, input().split()))

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

cnt = [0] *101
ans1 = 0
ans2 = 0

for _p in p:
    cnt[_p] += 1

for i in range(x, 101):
    if cnt[i] == 0:
        ans1 = i
        break

for i in range(x-1, -100, -1):
    if cnt[i] == 0:
        ans2 = i
        break

if abs(ans1 - x) < abs(ans2 - x):
    print(ans1)
elif abs(ans1 - x) >= abs(ans2 - x):
    print(ans2)
X,N = map(int,input().split())
if N == 0 :
    print(X)
else :
    P = list(map(int,input().split()))
    a = list(range(0,10000000))
    ab = 100
    an = []
    for i in range(N):
        a.remove(P[i])
        a = a
    for j in range(101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)
X,N=map(int,input().split())
P=list(map(int,input().split()))
t=0
for i in range(1,101):
    if i not in P:
        if abs(X-t)>abs(X-i):
            t=i
print(t)
x,n = map(int, input().split())

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

    i = 1
    while True:
        minus = x - i
        plus = x + i

        if not minus in ps:
            print(minus)
            break
        elif not plus in ps:
            print(plus)
            break
        
        i += 1
X, N = map(int, input().split())
P =  set(map(int, input().split()))
Nums = set(range(1, 101))
Nums = Nums - P
sorted(Nums)


minNum = 99999
minIndex = 0
for n in Nums:
    if minNum == abs(X-n):
        break
    if abs(X - n)< minNum:
        minNum = abs(X - n)
        minIndex = n

print(minIndex)
x,n=map(int, input().split())
nums=[int(x) for x in input().split()]
#print(nums)
if n == 0:
	print(x)
	exit()
min=x
gap=x
#print('Here')
for i in range(1,101):
	if i in nums:
		continue
	else:
		if abs(x-i) < gap:
			#print("min: ",min)
			#print(x-i)
			gap=x-i
			min = i
print(min)
X, N = map(int, input().split())
if N != 0:
  P = list(map(int, input().split()))
else:
  print(X)
  exit()
list = []
list2 = []
for i in range(100):
  if i not in P:
    res = abs(X - i)
    list.append(res)
    list2.append(i)
    
maxres = list.index(min(list))
print(list2[maxres])
def main():
  x,n = [int(i) for i in input().split()]
  table = list(map(int, input().split()))
  
  for i in range(101):
    if x - i not in table:
      print(x-i)
      exit()
    elif x + i not in table:
      print(x+1)
      exit()
    	
if __name__ == "__main__":
  main()
X,N=map(int, input().split())
p=list(map(int, input().split()))

ans1=100
ans=0
if N==0:
    print(X)
else:
    for i in range(100):
        if i in p:
            continue
        elif abs(X-i)<ans1:
            ans =i
            ans1 = abs(X-i)
    print(ans)
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    x,n = map(int, input().split())
    p = list(map(int, input().split()))
    l = [abs(i-x) if i not in p else 102 for i in range(101)]

    ans = l.index(min(l))
    print(ans)
    
if __name__ == '__main__':
    main()
import numpy as np
X,N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  min_val = -100
  max_val = 200
  not_p = [i for i in range(min_val,max_val+1,1)]
  
  for i in range(N):
    not_p.remove(p[i])

  min_val = 999
  out_num = 101
  for i in range(len(not_p)):
    if abs(X-not_p[i]) < min_val:
      min_val = abs(X-not_p[i])
      out_num = not_p[i]
else:
  out_num = 0
print(out_num)
x, n = map(int, input().split())

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

p.sort()

minp = 999
minv = x
if n == 100:
    print()
else:
    for i in range(1, 101):
        if i in p:
            continue
        else:
            if abs(i - x) < minp:
                minp = abs(i - x)
                minv = i
            else:
                break
    print(minv)
X, N = [int(i) for i in input().split()]
if N == 0:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    if not X in Ps:
        print(X)

    diff = 0
    while True:
        if not X - diff in Ps:
            print(X - diff)
            break
        if (not X + diff in Ps):
            print(X + diff)
            break
        diff += 1
X, N = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * 102
k = 999

for i in range(0, 101):
  for j in range(N):
    if p[j] == i:
      l[i] = 1
    j = j+1
  i = i+1
for i in range(-1, 100):
  i = i+1
  if l[i] == 1:
    continue
  k = min(k, abs(X-i))

if l[X-k] == 1:
    print(X+k)
else:
    print(X-k)
if __name__ == "__main__":
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    min_val = 0
    diff = abs(x-min_val)
    for i in range(1, 101):
        if diff > abs(x-i) and not(i in p):
            min_val = i
            diff = abs(x-min_val)
        elif diff < abs(x-i) and not(i in p):
            break

    print(min_val)
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
if n==0:
    print(x)
    exit(0)
ls=inp()
ls.sort()
ans=0
d=float('inf')
for i in range(101):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)
x,n=map(int,input().split())
if n>0:
    a=list(map(int,input().split()))     
    z=x+1
    y=x-1    
    while True:
        if y not in a:
            print(y)
            break
        elif z not in a:
            print(z)
            break
        z+=1
        y-=1
        #print(y,z)
else:
    print(x)
X, N = [int(i) for i in input().split(" ")]

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

p = {int(i) for i in input().split(" ")}

all_p = {i for i in range(max(p) + 1)}
ranges = all_p - p

diff = 1e9
ans = []
for i in ranges:
    if diff >= abs(i - X):
        if diff != abs(i - X):
            ans = []
        diff = abs(i - X)
        ans.append(i)

print(min(ans))
import sys
X,N = map(int,input().split())
if N == 0:
  print(X)
  sys.exit()
A = sorted(list(map(int,input().split())))

nl = []
a = 0
for i in range(A[0]-1,A[-1]+2):
  if i in A:
    a = a
  else:
    nl.append(i)
 
nnl = []
for i in range(len(nl)):
  nnl.append(abs(nl[i]-X))
  
print(min(nnl)+X)
k,n=map(int,input().split())
l=list(map(int,input().split()))
a=[]
for i in range (500):
	a.append(0)
x=0
for i in range(n):
	x=l[i]-k
	
	if x<0:
		a[2*abs(x)-1]=1
		
		
	else :
		a[2*x]=1
for i in range(200):
	if(a[i]==0):
		break
if(i%2==0):
	x=i/2
	print(k+x)
else:
	x=(i+1)/2
	print(k-i)
x, n = (int(i) for i in input().split())
P = [int(i) for i in input().split()]

ans, sa = 0, float('inf')
for q in range(101):
    if(abs(x - q) < sa and q not in P):
        ans = min(q, ans)
        sa = abs(x-q)
print(ans)
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
c=0
if n==0:
  print(x)
  sys.exit()
for i in range(x,-200,-1):
  c+=1
  if not i in p:
    print(i)
    sys.exit()
  if not (n+c) in p:
    print(n+c)
    sys.exit()
X, N = map(int, input().split())
P = set(list(map(int, input().split())))

targets = set(range(1, 101)) - P
if targets:
    print(min([(target, abs(X - target)) for target in targets], key=lambda x: x[1])[0])
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,101):
    if i in p:
        continue
    s = min(abs(x-i),s)
    

if not x-s in p and x-s > 0:
    print(x - s)
else:
    print(x + s)
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
if n==0:
    print(x)
    exit(0)
ls=inp()
ls.sort()
ans=0
d=float('inf')
for i in range(1, 102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))
flag = [False] * 101
for value in p:
    flag[value] = True
minAbs = 100
for i in range(1, 101):
    ab = abs(x - i)
    if not flag[i]:
        minAbs = min(minAbs, ab)
for i in range(1, 101):
    ab = abs(x - i)
    if not flag[i] and ab == minAbs:
        print(i)
        break
def resolve():
	X, N = map(int, input().split())
	if N == 0:
		print(X)
	else:
		A = list(map(int, input().split()))
		ymin = min(min(A), X)-1
		ymax = max(max(A), X)
		Y = {}
		for y in range(ymin, ymax):
			if y in A:
				None
			else:
				key = abs(X-y)
				if key in Y:
					Y[key] = Y[key] + [y]
				else:
					Y[key] = [y]
		key = min(Y.keys())
		print(min(Y[key]))
resolve()
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)!=0 and 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:
    l = list(map(int, input().split()))
    l.sort()
    small = x
    large = x
    while small in l and large in l:
        small -= 1
        large += 1
    if x - small > large - x:
        print(large)
    else:
        print(small)
(x,n) = input().split()
x = int(x)
p = input().split()
p = [int(i) for i in p]

result = x
sa = 100
count = 0
a = 0
for l in range(1,101):
    a = 1
    if l in p:
        continue
    
    if sa <= abs(x-l):
        result = count 
        break

    count = l
    sa = abs(x -l)
else:
    result = count
if a == 0:
    result = ""
print(result)
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

all = list(range(101))
val = 1000
# print(list(set(all) - set(p)))

for a in list(set(all) - set(p)):
    if abs(a - x) < val:
        ans = a
        val = abs(a - x)
        # print(val)
print(ans)
X,N = map(int,input().split())
if N == 0 :
    print(X)
else :
    P = list(map(int,input().split()))
    a = list(range(10000000))
    ab = 100
    an = []
    for i in range(N):
        a.remove(P[i])
    for j in range(101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)
x,n = map(int, input().split())
p = list(map(int, input().split()))
ans = 101
num = 0
for i in range(1,100):
    if i not in p:
        if abs(x - i) < ans:
            ans = abs(x - i)
            num = i
print (num)
X,N = map(int,input().split())
P = list(map(int,input().split()))


P_n = [i for i in range(105) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break
(X,N) = map(int,input().split())
p = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    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
X,N = map(int,input().split( ))
x = set(list(map(int,input().split( ))))
all_num = {i for i in range(1,101)}
ans = 1000
ans_num = 1000
for i in list(all_num - x):
    if abs(X - i) < ans_num:
        ans_num = abs(X-i)
        ans = i
    elif abs(X-i) == ans_num and i < ans :
        ans_num = abs(X-i)
        ans = i
print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))
d = [0]*201
for i in p: d[i+100] = 1
if d[x+100] == 0:
    print(x)
else:
    i = 1
    while True:
        if x-i>=-100:
            if d[x-i+100] == 0:
                print(x-i)
                break
        if x+i<=100:
            if d[x+i+100] == 0:
                print(x+i)
                break
        i += 1
X, N = [int(i) for i in input().split(" ")]

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

p = {int(i) for i in input().split(" ")}

all_p = {i for i in range(max(p) + 1)}
ranges = all_p - p

diff = 1e9
for i in ranges:
    if diff > abs(i - X):
        diff = abs(i - X)

ans_1 = X + diff
ans_2 = X - diff

for i in ranges:
    if i == ans_2:
        print(ans_2)
        break
else:
    print(ans_1)
x,n = map(int,input().split())
p_li = list(map(int,input().split()))
p_li.sort()
if p_li.count(x) == 0:
    print(x)
    exit()
dum1 = x-1
dum2 = x+1
for i in range(n):
    if p_li.count(dum1) == 0 and dum1 >= 1:
        print(dum1)
        exit()
    if p_li.count(dum2) == 0 and dum2 <= 100:
        print(dum2)
        exit()
    dum1 -= 1
    dum2 += 1
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))

s = 1
while True:
    if x - s not in p :
        print(x-s)
        exit()
    elif x + s not in p:
        print(x+s)
        exit()
    else:
        s += 1
X, N = map(int, input().split())
line = list(map(int, input().split()))
notLine = [i for i in range(-100, 201) if i not in line]
left = -1
right = len(notLine)
while abs(right - left) > 1:
    middle = (right + left) // 2
    if notLine[middle] >= X:
        right = middle
    else:
        left = middle
print(notLine[left], notLine[right])
if X - notLine[left] <= notLine[right] - X:
    print(notLine[left])
else:
    print(notLine[right])
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(0, 101)])
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)
m, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(m)
    exit()
else:
    pp = list(range(0, max(p)+1))
    ppp = list(filter(lambda x: x not in p, pp))
    pppp = list(map(lambda x: abs(x-m), ppp))
    print(ppp[pppp.index(min(pppp))])
x, n = map(int, input().split())
a = list(map(int, input().split()))
o = [0] * 101
o[0] = 1
for i in a:
    o[i] = 1

ans = 1000
dis = 1000
for i in range(1, len(o)):
    if o[i] == 0:
        if dis > abs(x - i):
            ans = i
            dis = abs(x-i)

print(ans)
x,n=map(int,input().split())
p=list(map(int,input().split()))
m=100
j=0
for i in range(1,101):
    if abs(x-i)<m and str(i) not in str(p):
        m=abs(x-i)
        j=i
print(j)
import sys
x,n = map(int,input().split())
p = list(map(int,input().split()))
s = 100
min_i = -1

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

for i in range(1,102):
    if i not in p and abs(i-x) < s:
        s = abs(i-x)
        min_i = i

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

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

A = [0]


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

if N == 0:
  print(X)
  exit()
  
p = list(map(int, input().split()))
r = 0
l = 0

for i in range(X + 1, 100 + 1):
  if not i in p:
    l = i
    break
    
for i in range(X - 1, -1, -1):
  if not i in p:
    r = i
    break

dl = abs(X - l)
dr = abs(X - r)

if dr <= dl:
  print(r)
else:
  print(l)
X, N = list(map(int,input().split()))
if N == 0:
  print(X)
  exit()
p = list(map(int,input().split()))
if N == 1:
  if p[0] == X:
    print(X-1)
  else:
    print(X)
ans = 0
d = 0
for i in range(N):
  if d < abs(X-p[i]):
    d = abs(X-p[i])
    
for i in range(d+1):
  if X - i not in p:
    ans = X - i
    print(ans)
    exit()
  elif X + i not in p:
    ans = X + i
    print(ans)
    exit()
X,N = map(int, input().split())
if(N == 0):
  print(X)
  exit()
else:
  p_list = list(map(int, input().split()))

i = X
ans_small = X
ans_big = X

while(True):
  i = i + 1
  #print("1",i)
  if((i in p_list)==True):
    pass
  else:
    ans_big = i
    break
    
i = X
while(True):
  i = i - 1
  #print("2",i)
  if((i in p_list)==True):
    pass
  else:
    ans_small = i
    break

#print(ans_big,ans_small)
if(abs(X-ans_small)>abs(X-ans_big)):
  print(ans_big)
else:
  print(ans_small)
x,y=map(int,input().split())
l=list(map(int,input().split()))
if x-1 not in l:
    print(x-1)
elif x-2 not in l:
    print(x-2)
elif x+1 not in l:
    print(x+1)
elif x+2 not in l:
    print(x+2)
else:
    print(x)
X,N=map(int,input().split())
if N==0:
    print(X)
else:
    w=input()
    w=w.split()
    t=list(w)
    b=list(range(-100,101))
    tt=[int(a) for a in t]

    ttt=set(tt)
    bb=set(b)

    c=bb^ttt

    cc=list(c)

    u=1000

    for s in cc:
        if abs(s-X)<u:
            u=abs(s-X)
    if (X-u) in cc:
            print(X-u)
    else :
            print(X+u)