peterverebics/CodeNet_Python_118 huggingface dataset:
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))
    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 = map(int,input().split())

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

_,res = min((abs(X-y),y) for y in range(-1,101) if y not in P)
print(res)
X,N = map(int,input().split())
l = list(map(int,input().split()))
n_l = sorted(l)

for i in range(N-2):
  if n_l[i]<= X < n_l[i+1]:
    print(n_l[i])
  else:
    print(n_l[N-1])
    break
x, n = map(int, input().split())
a = set(map(int, input().split()))
print(min(abs(i-x) for i in range(102) if i not in a))
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
List=list(map(int,input().split()))
num=list(range(1,101))
min_num=0
for i in range(len(List)):
    if num.count(List[i])>=1:
        num.remove(List[i])
for i in range(len(num)):
    if (abs(num[i]-x)<abs(min_num-x)) or (abs(num[i]-x)==abs(min_num-x) and num[i]<min_num):
        min_num=num[i]
print(min_num)
X, N = map(int,input().split())
p_list = list(map(int, input().split()))

p_list.sort()
r = 200
answer = 101

for i in range(0, 102):
    if i in p_list:
        continue
    else:
        if r > abs(i - X):
            r = abs(i - X)
            answer = i
        else:
            print(answer)
            break
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = float('inf')
m = float('inf')
for i in range(-1, 101):
    if i in p:
        continue
    else:
        if abs(x - i) < m:
            ans = i
            m = abs(x - i)
print(ans)
X,N = map(int,input().split())
P = set(map(int,input().split()))


diff=float('inf')
ans=-1
for i in range(-100,110):
    if i in P:
        continue
    d = abs(X-i)
    if d<diff:
        ans=i
print(ans)
X,N=map(int,input().split())
p=list(map(int,input().split()))
ans=0
m=100
for i in range(100):
    if m>(i+1)-X and (not i+1 in p):
        ans=i+1
        m=abs((i+1)-X)
print(ans)
x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))
p = [-1] + p + [101]
import bisect
p.sort()
i = bisect.bisect_left(p,x)

for h in range(p[-1]-p[0]+1):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()
X,N = map(int, input().split())
P=sorted(list(map(int, input().split())))
if (N == 0):
  print(X)
  exit(0)

ans=float('inf')
tmpX=X
while X <= 100:
  if X not in P:
    ans = X
    break
  X = X+1

while tmpX >= 1:
  if tmpX not in P:
    ans = min(tmpX, ans)
    break
  tmpX = tmpX-1
print(ans)
if __name__ == '__main__':
    x, n = map(int, input().split())
    if n >0:
        a = [int(i) for i in input().split()]
        listN = [i for i in range(100)]
        diffList = list(set(listN) -set(a) )
        ans = 0
        diff = 100
        for i in diffList:
            now = abs(i-x)
            if diff > now:
                diff=now
                ans =i
        print(ans)
    else:
        print(x)
def main():
    x,n = tuple([int(t)for t in input().split()])

    p = tuple([int(t)for t in input().split()])

    nums = set(range(1,101))
    nums.add(-1)
    nums.add(101)

    for p_i in p:
        nums.discard(p_i)

    dist = 10**8
    ans = -1
    for i in nums:
        if dist>abs(x-i):
            dist = abs(x-i)
            ans = i

    print(ans)
if __name__ == "__main__":
    main()
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(1,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())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    if x + df > 0 and not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    df += 1
X,N=map(int,input().split())
p=list(map(int,input().split()))
p_bar=[]
for i in range(1,101):
  if i not in p:
    p_bar.append(i)

d_min=1000
i_min = 0
for i in p_bar:
  d = abs(X-i)
  if d < d_min:
    d_min = d
    i_min = i
print(i_min)
import sys
N , M = (map(int , input().split()))
if M == 0:
    print(N)
    sys.exit()
A = list(map(int , input().split()))
aa = [i for i in range(1,101)]
ans_list = {}
for i in aa:
    if i not in A:
        ans_list.update({i:abs(N-i)})
for i in ans_list:
    if ans_list[i] == min(list(ans_list.values())):
        print(i)
        sys.exit()
X, N = map(int, input().split())
p = set()
if N != 0:
    p = set(map(int, input().split()))
pp = sorted(list({i for i in range(101)} - p))
ans = -100
for i in pp:
    if abs(X - ans) > abs(X - i):
        ans = i
print(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(-200,200):
  if i in A:
    a = a
  else:
    nl.append(i)
 
nnl = []
for i in nl:
  nnl.append(abs(i-X))

if X in nnl:
  print(X-1)
elif nnl.count(min(nnl)) != 2:
  print(X+min(nnl))
else:
  print(X-min(nnl))
XN = input().split()
P = input().split()
X = int(XN[0])
N = int(XN[1])
pi = [int(a) for a in P]
if N == 0:
    print(X)
    exit()
i = 1
while True:
    koho1 = X + i
    koho2 = X - i
    if not koho2 in pi:
        print(koho2)
        break
    elif not koho1 in pi:
        print(koho1)
        break
    else:
        i = i + 1
        continue
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
lst = list(map(int, input().split()))

def search(l, x, i=1):
    min_, max_ = x-i, x+i
    if not min_ in l and not max_ in l:
        return min_
    if not min_ in l:
        return min_
    if not max_ in l:
        return max_
    return search(l, x, i+1)

print(search(lst, x))
from bisect import bisect_left

x,n=list(map(int,input().split()))
if n:
  A=list(map(int,input().split()))
else:
  print(x)
  exit()
  
for i in range(n):
  if x-i in A and x+i in A:
    continue
  elif x+i in A or (not x-i in A and not x+i in A):
    print(x-i)
    break
  else:
    print(x+i)
    break
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()

P = list(map(int, input().split()))
t = 101
for i in range(101):
  if not i in P:
    if t > abs(i - x):
      t = abs(i - x)
      ans = i

print(ans)
from collections import defaultdict
x, n = map(int, input().split())
p = list(map(int, input().split()))

c = [i for i in range(1,201)]
s = set(p)
d = set(c)-s
# print (d)

ans = [[] for i in range(200)]
for i in list(d):
  a = 0
  y = abs(i-x)
  ans[y].append(i)

for i in ans:
  if len(i) == 0:
    continue
  print (min(i))
  exit()
x,n=map(int,input().split())
if(n==0):
  print(x)
else:
  l=list(map(int,input().split()))
  d=100
  for i in range(101):
      if(i not in l and (abs(i-x)<d)):
          d=abs(x-i)
          m=i
  print(m)
a,b = map(int,input().split())
if b == 0:
    print(a)
else:
    c = list(map(int,input().split()))
    for i in range(1,b+1):
        if (a-i not in c) or (a+i not in c):
            if a +i in c:
                print(a+i)
                break
            else:
                print(a-i)
                break
# 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
      else:
        cnt=i
      if cnt>n:
          break
    print(cnt)
a, b = map(int, input().split())
list2 = set(map(int, input().split()))
list1=list(range(1,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)
    exit(0)
for abs in range(n):
    if (x - abs) not in p:
        print(x-abs)
        exit(0)
    elif (x + abs) not in p:
        print(x+abs)
        exit(0)
X, N = map(int, input().split())
Y = list(map(int, input().split()))
x = int(X)
print(x)
for i in range(100):
    if x - i in Y:
        print(x + i)
        break
    elif x + i in Y:
        print(x - i)
        break
x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))
p = [-1] + p + [101]
import bisect
p.sort()
i = bisect.bisect_left(p,x)

for h in range(102):
  if p[i] != x:
    print(x)
    exit()
  elif p[i-h] != x-h:
    print(p[i])
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()
import sys

X, N = map(int, input().split())
P = list(map(int, input().split()))
NL = [i for i in range(-100, 1000) if i == X or i not in P]

if len(P) == 0:
    print(X)
    sys.exit()

idx = NL.index(X)
if abs(NL[idx + 1] - X) >= abs(NL[idx - 1] - X ):
    print(NL[idx - 1])
else:
    print(NL[idx + 1])
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline

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

if(N==0):
    ans=X
else:
    ListP=list(map(int,input().split()))

    min = 999999
    for i in range(-101,101):
        if(min > abs(X-i)):
            if(i not in ListP):
                min=abs(X-i)
                ans=i


print(ans)
x,n = map(int,input().split())
p = [0] + list(map(int,input().split()))
ans = []
for i in range(max(p)+2):
    if i not in p:
        ans.append([abs(i-x),i])
ans.sort()
print(ans[0][1])
def solve():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    l = [int(i) for i in range(100, -1, -1)]
    for i in range(n):
        l.remove(p[i])
    ans = 101
    for i in range(len(l)):
        if ans >= abs(l[i]-x):
            ans = abs(l[i]-x)
        else:
            return l[i-1]
    



print(solve())
def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    min = 100000
    ans = 0
    for i in range(101):
        if i in p:
            pass
        elif min > abs(i-x):
            min = abs(i-x)
            ans = i
            
    print(ans)

if __name__ == "__main__":
    main()
x , n = map(int , input().split())
p = list(map(int , input().split()))

ans = 0

for i in range(n):
    tmp1 = x - i
    tmp2 = x + i
    if not tmp1 in p:
        ans = tmp1
        break
    if not tmp2 in p:
        ans = tmp2
        break

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

try:
  p = set(map(int, input().split()))
  num = set(range(-100,201))
  mem = []

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(item - X))
  
  print(ref)
  print(mem)
  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

for i in range(0, 101):
    a = x - i
    b = x + i

    if a >= 1 and a not in p:
        print(a)
        break
    elif b <= 100 and b not in p:
        print(b)
        break
X,N= map(int,input().split())
p = list(map(int, input().split()))
ans_tmp = 10**9+7
ans = 0
if N==0:
    print(X)
else:
    for i in range(0,102):
        if i not in p and ans_tmp>abs(X-i):
            ans_tmp=abs(X-i)
            ans = i
print(ans)
x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
y = 101
#ans = x
if n == 0:
  print(x)
else:
  for i in range(-100,102):
    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('i=',i,'abs=',abs(x-i),'ans=',ans)
  print(ans)
x,n=map(int,input().strip().split())
s=list(map(int,input().strip().split()))
a=0
b=x-1
c=1
while a==0:
    a=1
    for i in range(n):
        if(b==s[i]):
            a=0
    if(b<x and a==0):
        b+=c*2
    elif(b>x and a==0):
        b-=c
        c+=1
        b-=c
print(b)
import sys
X, N = map(int, input().split())
p = list(map(int, input().split()))

a = -1
if not p:
    print(X)
    sys.exit()

for i in range(1, 101):
    tmp_1 = X - i
    tmp_2 = X + i
    if tmp_1 not in p:
        print(tmp_1)
        sys.exit()
    elif tmp_2 not in p:
        print(tmp_2)
        sys.exit()
n = input().split()
n = [int(i) for i in n]
m = input().split()
m = [int(i) for i in m]
 
ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[1])
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
    if not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))
import sys

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

a = []
b = []

for i in range(0, 101):
    if i not in p:
        a.append(abs(x - i))
        b.append(i)
ans = min(a)
bb = a.index(ans)
print(b[bb])
x,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(0)
else:
    for i in range(1,101):
        if x-i not in p:
            print(x-i)
            break
        elif x+i not in p:
            print(x+i)
            break
import numpy as np
X,N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  min_val = 1
  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])
  #print(not_p)

  min_val = 101
  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)
#!/usr/bin/env python3

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

d = [0 for _ in range(-1000, 1001)]
for i in range(-1000, 1001):
    d[i] = i+1 

for i in p:
    d.remove(i)

d2 = [0 for _ in range(len(d))]
for i in range(len(d)):
    d2[i] = abs(d[i]-x)

m = 10000
for i in reversed(range(len(d2))):
    if d2[i] <= m:
        m = d2[i]
        tmpi = i 

print(d[tmpi])
def MI():
    return map(int, input().split())

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

X, N = MI()
P = LI()
ans = X

if len(P) == 0:
    print(ans)
    exit()

for i in range(101):
    if X - i in P:
        ans = X - i
        break
        
    if X + i in P:
        ans = X + i
        break

print(ans)
intX, length = map(int, input().split())
intList = input().split()
intList = [int(x) for x in intList]

for i in range(intX):
    if intX - i not in intList:
        print(intX - i)
        break
    elif intX + i not in intList:
        print(intX + i)
        break
X,N=map(int,input().split())
p=list(map(int,input().split()))
if N==0:
  print(X)
else:
  for i in range(1,N):
    if abs(N-i) not in p or abs(N+i) not in p:
      print(max([abs(N-i),abs(N+i)]))
      break
X, N = map(int, input().split())
if N>0:
  p = [int(i) for i in input().split()]
else:
  p = [-1]
  
p = sorted(p)
#print(p)

try:
  idx=p.index(X)
  flag=False
  for i in range(N):
    for o in [-1,+1]:
      if idx+(i*o) < 0 or idx + (i*o) >= N:
        print(X+(i*o))
        flag=True
        break
      elif X+(i*o)!=p[idx+(i*o)]:
        print(X+(i*o))
        flag=True
        break
    if flag:
      break
except:
  print(X)
x, n = map(int, input().split(" "))
v = [i+1 for i in range(100)]
min_val = 100
ans_index = 0

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


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


#print("")
print(ans_index)
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

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


a = list(range(101))

for i in lis:
    a.remove(i)

ans = 10000    
tans = 0
for j in a:
    tmp = abs(j-x)
    if tmp < ans:
        tans = j
        ans = tmp
        
print(tans)
x,n = map(int, input().split())
p = list(map(int, input().split()))


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


p.sort()
min = abs(x-p[0])
win = 101
for i in range(0, 101, 1):
  if (i in p):
    continue

  sa = abs(i - x)
  if ( sa < min ):
    min = sa
    win = i
  elif ( sa == min ):
    if ( i > win ):
      win = win
    else:
      win = i

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

li = []
for i in range(-1, 101):
    if i not in P:
        li.append(i)

ans = -1
minimum_num = 200

for n in li:
    num = abs(n - X)
    if num < minimum_num:
        minimum_num = num
        ans = n

print(ans)
x,n=input().split()
a = list(map(int,input().split()))
if a==[]:
    print(int(x))

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

try:
    p = list(map(int, input().split()))
except:
    print(X)
    exit()

if p.count(X) == 1:
    for i in range(1,N + 1):
        if p.count(X - i) != 1 or p.count(X + i) != 1:
            if p.count(X - i) == 1:
                print(X + i)
                exit()
            else:
                print(X - i)
                exit()
X,N=map(int, input().split())
if(N==0):
  print(X)
  exit()
if(X==100 and N==100):
  exit()
P=list(map(int, input().split()))
P.sort()
mi=1000
cotae=1000
for i in range(1,100):
  if(i in P):
    continue
  if(abs(X-i)<mi):
    mi=abs(X-i)
    cotae=i
print(cotae)
def main():
  x, n = list(map(int, input().split()))

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

  min_abs = 101
  min_e = 0
  for i in p:
    if abs(x-i) < min_abs:
      min_abs = abs(x-i)
      min_e = i

  if min_abs != 0:
      print(min_e)
      return
      
  for i in range(1, 100):
    if min_e - i not in p:
      print(min_e - i)
      return
    elif min_e + i not in p:
      print(min_e + i)
      return
    
main()
x, n = map(int, input().split())
if n == 0:
	print(x)
	exit()
p = list(map(int, input().split()))
mind = abs(x - p[0])
pos = [p[0]]
s = set(p)
p = []
for x1 in range(-100, 200):
	if x1 in s:
		continue
	else:
		p.append(x1)
for q in p:
	if abs(x - q) < mind:
		mind = abs(x - q)
		pos = [q]
	elif abs(x - q) == mind:
		pos.append(q)
pos.sort()
print(pos[0])
x,n = map(int,input().split())
if n!=0:
    p = list(map(int,input().split()))
    li = set([i for i in range(1,101)])
    li = li-set(p)
    k=10**9
    m=0
    li=sorted(list(li))
    for i in li:
        if k>abs(x-i):
            k=abs(x-i)
            m=i
    print(m)
else:
    print(x)
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
elif N == 100:
  if X <= 50:
    print(0)
  else:
    print(101)
  exit()
else:
  p = set(map(int, input().split()))

l = X
d = 0
for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)
s = input().split()

x = int(s[0])
n = int(s[1])

s = {i for i in range(-1,102)}

p1 = input().split()

p = set()

for i in p1:
    p.add(int(i))

t = s - p

answer = 20000

for i in t:
    if (x - abs(int(i)) < x - abs(answer)) or (x - abs(int(i)) == x - abs(answer)) and i < answer:
        answer = int(i)

print(answer)
x, n = map(int, input().split())
p = list(map(int, input().split()))
cnt = 0
s = 0
o = 0
while True:
    if not(x - cnt in p):
        s = x - cnt
    if not(x + cnt in p):
        o = x + cnt
    if s != 0 or o != 0:
        break
    cnt += 1
if s != 0 and o != 0:
    if s < o:
        print(s)
    else:
        print(o)
elif s != 0:
    print(s)
elif o != 0:
    print(o)
x, n = map(int, input().split())
if n ==0:
    print(x)
else:
    p = list(map(int, input().split()))
    q = list(range(101))
    a = 0
    for i in range(x, 0, -1):
        if p.count(i) == 0:
            a = i
            break

    b = 0
    for i in range(x, 101):
        if p.count(i) == 0:
            b = i
            break

    if abs(x-a) > abs(x-b):
        print(b)
    else:
        print(a)
x,n = map(int,input().split())
p = list(map(int,input().split()))
q = set(range(-2,101))
q = q - set(p)
q_list = list(q)
ans = 1000
d = 1000
print(q_list)
for i in range(100-n):
   if d != min(d,abs(x - q_list[i])):
       ans = q_list[i]
       d = min(d,abs(x - q_list[i]))
       print(ans,d)
print(ans)
X,N = map(int,input().split())
p_li = set(map(int,input().split()))
p = set(range(101))
kouho = p - p_li
ans = 10000
sa_min = 1000000
for i in list(kouho):
    sa = abs(X-i)
    if sa_min > sa:
        ans = i
        sa_min = sa
print(ans)
X,N = map(int,input().split())
l=list(map(int,input().split()))
tmp1=X
tmp2=X
if N==0:
    print(X)
else:
    while True:
        if not tmp1-1 in l:
            print(tmp1-1)
            exit()
        else :
            tmp1-=1
        if not tmp2+1 in l:
            print(tmp2+1)
            exit()
        else:
            tmp2+=1
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
X, N, *p = map(int, read().split())
p=list(p)
 
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			#exit(0)
import numpy as np
oin = input()
x, n = int(oin.split(" ")[0]), int(oin.split(" ")[1])
if n == 0:
  print(x)
  exit()
p = input().split(" ")
xpo = x+1
xdetect = list(range(0, 101))
if x == 1 and 1 in p:
  print(0)
  exit()
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]
for b in p:
  try:
    xdetect.remove(int(b))
  except ValueError:
    continue
print(getNearestValue(xdetect, x))
x,n=map(int,input().split())
ar=[int(i) for i in input().split()]
arr=[i for i in range(1,1000) if i not in ar]
arr.sort()
mini=10000000
for i in arr:
    if abs(i-x)<mini:
        mini=abs(i-x)
        ans=i 
print(ans)
x,n=map(int,input().split())
if n == 0:
  print(x)

l=list(map(int, input().split()))
a = x
b = x

if not x in l:
  print(x)
else:
  for i in range((len(l)-1)//2):
    a -= 1
    b += 1
    if not a in l and not b in l:
      print(a)
      break
    elif a in l and not b in l:
      print(b)
      break
    elif not a in l and b in l:
      print(a)
      break
    else:
      pass
      if i == (len(l)-1)//2 - 1:
        print(a - 1)
a=list(map(int,input().split()))
p=list(map(int,input().split()))
x=a[0]
n=a[1]
b=list(range(101))
c=list(set(p)^set(b))
c.append(x)
nl=sorted(c)
k=nl.index(x)
i=x-nl[k-1]
if k==len(nl)-1:
    j=105
else:
    j=nl[k+1]-x
if i<=j:
    print(nl[k-1])
else:
    print(nl[k+1])
x,n = map(int,input().split())
p = list(map(int,input().split()))
print(p)
for i in range(100):
    for j in p:
        if j == (x - i):
            break
    else:
        print(x - i)
        break
    for j in p:
        if j == (x + i):
            break
    else:
        print(x + i)
        break
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*102
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 102):
    if m[j] != 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
      else:
        ans = A
      break
print(ans)
x,n = map(int,input().split())

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


a = 0
for m in range(100 + 1):
    if m in p:
        continue
    else:
        if abs(x - a) > abs(x - m):
            a = m

print(a)
x, n, *P = map(int, open(0).read().split())
A = list(range(102))
P = set(P)
B = []
m = 10**4
for a in A:
    if a not in P:
        if abs(x-a) < m:
            m = abs(x-a)
            B.append((m, a))
print(min([k for v, k in B if v == B[0][0]]))
x, n = map(int, input().split())

if n == 0:
  print(x)
else :
  pn = [int(num) for num in input().split()]
  answers = {}
  for i in range(0,100):
    if not i in pn:
      answers[i] = abs(i-x)
  print(min(answers, key=answers.get))
X, N = map(int, input().split())
ps = list(map(int, input().split()))

pset = set([abs(X-p) for p in ps])

for i in range(50):
  if i in pset:
    print(X-i)
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(-100,101)]
b = sorted(list(set(a) - set(p)))
min_v = 1000
min_id = 0
for i in range(len(b)):
  if abs(x - b[i]) < min_v:
    min_v = abs(x - b[i])
    min_id = i
print(b[min_id])