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

p_list = sorted(p_list)
all_range = list(range(101))
A = [i for i in all_range if i not in p_list]
B = [abs(i - X) for i in A]

low = X - min(B)
high = X + min(B)

if N == 0:
  print(X)
elif high in p_list:
  print(low)
elif low in p_list:
  print(high)
else:
  print(low)
x,n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))

a = 0
for i in range(x-1, -1, -1):
  if i not in p:
    a = i
    exit()
b = 0
for i in range(x, 101):
  if i not in p:
    b = i
    break

if abs(x-a) <= abs(x-b):
  print(a)
else:
  print(b)
x,n = map(int, input().split())
l = sorted(list(map(int, input().split())))
num = [0] * 101

for i in l:
    num[i] += 1
ans = 0
minNum = float('inf')
for i in range(1,len(num)):
    if num[i] == 0:
        numx = abs(x - i)
        if numx < minNum:
            minNum = numx
            ans = i
print(ans)
x, n = (int(i) for i in input().split())
P = [int(i) for i in input().split()]

ans, sa = float('inf'), 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)
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


x,n=MAP()
if n==0:
    print(x)
    exit()
a=LI()
l=-1;r=-1
for i in range(1,100):
    if x-i not in a:
        l=x-i
        break
for i in range(1,100):
    if x+i not in a:
        r=x+i
        break
if abs(r-x)>=abs(l-x):
    print(l)
else:
    print(r)
x, n = map(int, input().split())

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

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

ans = 1001001
tmp = 1001001
for i in range(p[0]-1, p[-1]+1):
    if i in p: continue
    if abs(x-i) < tmp:
        tmp = abs(x-i)
        ans = min(ans, i)

print(ans)
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
P = list(map(int, input().split()))
 
for i in range(X+1):
  for d in [-1, +1]:
    if not X+i*d in P:
      print(X+i*d)
      break
def main():
    X, N = map(int, input().split())
    P = set(map(int, input().split()))

    ans = min(
        (i for i in range(0, 101) if i not in P),
        key=lambda x: abs(X - x)
    )
    print(ans)


if __name__ == '__main__':
    main()
from sys import stdin
x, n = map(int, stdin.readline().rstrip().split())
if n ==0:
    print(x)
else:
    data = list(map(int, stdin.readline().rstrip().split()))

    data_sorted = sorted(data)

    abs_min = 100000000
    res = data_sorted[0]-1
    for i in range(data_sorted[0]-1, data_sorted[-1]+1):
        if (i in data_sorted) == False and abs_min > abs(i-x):
            abs_min = abs(i-x)
            res = i
    print(res)
x,n = map(int, input().split())
p = list(map(int, input().split()))


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


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

  sa = abs(i - x)
  if ( sa < min ):
    print('sa:{}'.format(sa))
    min = sa
    win = i
  elif ( sa == min ):
    if ( i > win ):
      win = win
    else:
      win = i

print (win)
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
X,N = LI()
p = set(LI())
ans,distance = 0,float('INF')
for x in range(101)[::-1]:
    if x in p:
        continue
    now_distance = abs(X-x)
    if now_distance<=distance:
        ans = x
        distance = now_distance
print(ans)
X,N = map(int,input().split())
l=list(map(int,input().split()))
tmp1=X
tmp2=X
if not l:
    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
x,n=map(int,input().split())
p=list(map(int,input().split()))
l=[]
for i in range(0,101):
  if i not in p:
    l.append(i)

c=[]
for ll in l:
  c.append(abs(x-ll))
print(l[c.index(min(c))])
X, N = map(int, input().split())
P = set(list(map(int, input().split())))

targets = set(range(-101, 101)) - P
if targets:
    print(min([(target, abs(X - target)) for target in targets], key=lambda x: x[1])[0])
else:
    print(X)
# coding: utf-8
# Your code here!

import numpy as np

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

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

m = np.array(list(range(-100,200)))
m = (m-x)**2
for i in (np.argsort(m)-100):
    if p.count(i) == 0:
        print(i)
        break
m, n = map(int, input().split())
p = list(map(int, input().split()))

for d in range(m+1):
    for i in [-1,1]:
        a = m + i*d
        if p.count(a==0):
            print(a)
            exit()
X, N = map(int, input().split(" "))
if N == 0:
  print(X)
  exit()
else:
  p = list(map(int, input().split(" ")))
  c = -1
  for i in range(100):
    if i+1 not in p:
      if abs(X-(i+1)) < abs(X-c):
        c = i+1
  print(c)
x, n = (int(each) for each in input().split())
if n == 0:
    print(x)
else:
    p = [int(each) for each in input().split()]
    candidate = 0
    for i in range(max(p)):
        if i not in p and abs(i-x) < abs(candidate-x):
            candidate = i
            # print('replaced')
    print(candidate)
x,n = map(int,input().split())
p = list(map(int,input().split()))
p_ans = [200] * 201
count = 0
for i in range(-100,101):
    if not(i in p):
        p_ans[count] = abs(x-i) 
    count += 1
p_min = min(p_ans)
for i in range(len(p_ans)):
    if p_min == p_ans[i]:
        print(i-100)
        exit()
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
elif n==100:
    print(-1)
    exit()
List=list(map(int,input().split()))
num=list(range(-1000,1000))
min_num=1000000000
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)
import math

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

ans = -1
dif = 10000
for i in range(1,101):
    if i in p:
        continue
    else:
        if abs(x - i) < dif:
            ans = i
            dif = abs(x - i)

print(ans)
# X:整数　N:長さ
# p1 ... pN
# 含まれない整数のうちXに近いものを答える
X, N = map(int, input().split())
p = list(map(int, input().split()))
for i in range(X, -50, -1):
    if i not in p:
        l = i
        break
for j in range(X, 201):
    if j not in p:
        r = j
        break
print(l if abs(l-X) < abs(r-X) else r)
#C
import numpy as np
x, n = map(int, input().split())

if n!=0:
    p_list = list(map(int, input().split()))
    
    if n%2==0:
        kouho = list(range((x-n//2-1),(x+n//2)))
    else:
        kouho = list(range((x-n//2-1),(x+n//2+1)))
        
    kouho2 = set(kouho) - set(p_list)
    ans = [j for i, j in enumerate(list(kouho2)) if abs(j-x) == min(abs(np.array(list(kouho2)) - x))]
    ans = min(ans)

else:
    ans = [x]

print(ans)
x,n = map(int,input().split())
P  = list(map(int,input().split()))
ans = 0
neko = float("inf")
for i in range(-100,101):
    if i in P:
        continue
    if neko > abs(i - x):
        neko = abs(i - x)
        ans = i
print(ans)
X,N=map(int,input().split())
P=list(map(int,input().split()))
def b():
    if(N==0):
        return X
    for n in range(1,N+3):
        a=X-n
        if(a not in P):
            return a
        a=X+n
        if(X+n not in P):
            return a
print(b())
X,N = input().split(' ')
x =int(X)
n = int(N)
try:
    kara_int = list(map(int,input().split(' ')))
except ValueError:
    print(X)
except EOFError:
    print(X)


for s in range(n):
    if x+s not in kara_int and x-s not in kara_int:
        if x-s in kara_int:
            print(str(x+s))
        else:
            print(str(x-s))
        break
X, N = map(int, input().split())
p_list = [int(i) for i in input().split()]

if N == 0:
    print(X)
else:
    check_list = []
    for i in range(1, 101+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())
if N>1:
    p_set = set(map(int,input().split()))
else:
    p_set = set()

min_dist_xp = 1000
for p in reversed(range(0,102)):
    if p not in p_set:
        dist_xp = abs(X-p)
        if dist_xp<=min_dist_xp:
            min_dist_xp = dist_xp
            ans = p

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

for i in range(n//2 +1):
    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())
l=list(map(int,input().split()))
s=set()
p=x
res=0
while(True):
  if(not(p in l)):
    res=p
    break
  p-=1
s.add(res)
while(True):
  if(not(x in l)):
    res=x
    break
  x+=1
s.add(res)
print(min(s))
X,N=map(int, input().split())
p=list(map(int, input().split()))

a = 101
num = 0

for i in range(101):
    if i not in p:
        b = i-X
        if abs(b) < a:
            a = abs(b)
            num = i

print(num)
X,N=map(int, input().split())
if(N==0):
  print(X)
  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 test(X, N, p):
    list_abs = [abs(n) for n in p]
    list_abs.sort()
    list_b = [int(n) for n in range(-1*list_abs[-1], list_abs[-1])]
    list_all = list(set(p) ^ set(list_b))
    list_all = [abs(n-X) for n in list_all]
    list_all.sort()
    return X+list_all[0]


if __name__ == '__main__':
    X, N = map(int, input().split())
    if N == 0:
        print(N)
    else:
        p = [int(n) for n in input().split()]
        print(test(X, N, p))
import numpy

x,n = map(int,input().split())
try:
    p = list(map(int,input().split()))
except EOFError:
    p =[]

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()

if 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        print(x-i)
        break
x, n = map(int, input().split())
p = {int(i) for i in input().split()}
abs_d = 0
while x in p:
    for d in {-abs_d, abs_d}:
        x += d
        if x not in p:
            print(x)
            break
    abs_d += 1
X,N = list(map(int,input().split()))

i = 0
if N != 0:
  
  pn = list(map(int,input().split()))
  pall = list(range(101))
  test = list(set(pall) - set(pn))
  ans = []
  
  while i < len(test):
    if X - N//2 -1 <= test[i] <= X + N//2 :
      ans.append(test[i])
    i += 1
  print(min(ans))
else:
  print(X)
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  for i in range(100):
    if i % 2 == 0:
      a = -1
    else:
        a = 1
    b = i // 2
    y = x + a*b
    if not y in p:
      print(y)
      exit()
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = set(map(int, input().split()))
    NP = [i for i in range(1, 101) if i not in P]
    mx = 100
    for p in NP:
        if abs(x-p) < abs(x-mx):
            mx = p
    print(mx)
x,n = map(int,input().split())
p = list(map(int,input().split()))

min=0
dev=200

for i in range(1,102):
  if i in p or abs(x-i)>=dev:
    continue
  dev=abs(x-i)
  min=i
print(min)
x,n=map(int,input().split())
p=list(map(int,input().split()))
y=x
z=x
if x not in p:
    print(x)
    exit()
for i in range(2*len(p)):
    y-=1
    z+=1
    if y not in p:
        print(y)
        print('owari')
        exit()
    if z not in p:
        print(z)
        print('owari')
        exit()
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
an = 0
if n ==100:
    print(0)
    sys.exit()
for i in range(102):
    #if x!=i:
    if p.count(i)==0:
        if abs(x-i)<wk:
            an =i
            wk = abs(x-i)

print(an)
X, N = [int(x) for x in input().split()]
array = [int(x) for x in input().split()]
plus = X
minus = X
if N == 0:
    print(X)
    exit()
while True:
    plus += 1
    minus -= 1

    if minus not in array:
        print(minus)
        exit()
    if plus not in array:
        print(plus)
        exit()
x,n=[int(_) for _ in input().split()]
p=[int(_) for _ in input().split()]
p.sort()

pinv=[True for i in range(101)]
pinv[0]=True
for i in p:
    pinv[i]=False

ab=100
ans=0
for i in range(101):
    if pinv[i] and abs(x-i)<ab:
        ab=abs(x-i)
        ans=i

print(ans)
X, N = [int(x) for x in input().strip().split()]
p = set([int(x) for x in input().strip().split()])
ans = 0
diff = X
for i in range(102):
  if i in p:
    continue
  if abs(X - i) < diff:
    ans = i
print(ans)
X,N = map(int,input().split())
P = list(map(int,input().split()))

#
P_n = [i for i in range(1,102,1) if i not in P]
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())
if N == 0:
    print(100)
    ans = X
    exit()

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

for i in range(N):
    if X-i not in P:
        ans = X-i
        break
    elif X+i not in P:
        ans = X+i
        break

print(ans)
x,n = [int(x) for x in input().split()]
if n == 0:
  print(x)
else:
  p = [int(x) for x in input().split()]
  p.sort()
  a = 1000
  for i in range(n):
    b = abs(x - p[i])
    if b < a:
      a = i
  print(a)
X, N = list(map(int, input().split()))
if N==0:
    print(X)
else:
    ps = list(map(int, input().split()))
    sub_abs = 0
    while True:
        if (X-sub_abs) not in ps:
            print(X-sub_abs)
            break
        if (X+sub_abs) not in ps:
            print(X+sub_abs)
        sub_abs += 1
#input from user X and N
#input from user p
#print the number that is nearest to X but not included in p
#if N = 0, p doesn't have to be taken, only X will be printed
#time complexity O(n)

X,N = [int(x) for x in input().split()]
p = [int(x) for x in input().split()[:N]]


a = X + 1
b = X - 1
if a < b :
    if a not in p:
        print(a)

elif b < a:
    if b not in p:
        print(b)
x,n=map(int,input().split())
p=set(map(int,input().split()))
tmp=1000000
ans=0
for i in range(1,110):
    if i not in p:
        if tmp>abs(i-x):
            ans=i
            tmp=abs(i-x)
print(ans)
X,N=map(int,input().split())
p_list=list(map(int,input().split()))
ans=0
f_list=list(range(101))
for i in p_list:
    f_list.remove(i)
for i in f_list:
    if abs(X-ans)>abs(X-i):
        ans=i
print(ans)
from typing import List


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

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

    p_lst: List[int] = list(map(int, input().split()))

    for i in range(50):
        if X - i not in p_lst:
            print(X - i)
            exit()
        if X + i not in p_lst:
            print(X + i)
            exit()


if __name__ == "__main__":
    main()
x, n = map(int, input().split())
p = list(map(int, input().split()))
if x not in p:
    print(x)
a, b = 1, 1
while True:
    if (x + a) not in p:
        break
    else:
        a += 1

    while True:
        if (x - b) not in p:
            break
        else:
            b += 1

if a >= b:
    print(x - b)
else:
    print(x + a)
import bisect
X,N = map(int,input().split())

p = list(map(int,input().split()))
p = sorted(p,reverse = False)
p_x = []
if p == []:
    print(X)
else:
    for i in range(-1,200):
        if not(i in p):
            p_x.append(i)#番兵
    idx_x = bisect.bisect_left(p_x,X)
    if abs(X-p_x[idx_x-1]) < abs(X-p_x[idx_x]):
           print(p_x[idx_x-1])
    else:
           print(p_x[idx_x])
X,N = map(int,input().split())

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

p = list(map(int,input().split()))
p.sort()
q = [i for i in range(-1000,1000)]
li = set(p) ^ set(q)
tmp = 1
ans = 0
while(1):
    if X-tmp in li:
        ans = X-tmp
        break
    elif X+tmp in li:
        ans = X+tmp
        break
    tmp += 1
print(ans)
X, N = map(int, input().split())
p = list(map(int, input().split()))

mindif = 1000
candidate = 0
for i in range(-1, 101):
    if abs(i - X) < mindif and i not in p:
        mindif = abs(i - X)
        candidate = i

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

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

d = float("inf")
ans = -1
for n in reversed(range(101)):
    if not n in P and abs(X - n) < d:
        ans = n
        d = abs(X - n)

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

diff = 1000
for i in range(-100, 101):
    if i in p:
        continue
    if abs(i - x) < diff:
        diff = abs(i - x)
        ans = i

print(ans)
import sys
sys.setrecursionlimit(10000000)

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

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


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

l=[0] * 100

for i in p:
    l[i-1] =1

diff=min(101-x,x)
ans=-1 if x < 51 else 101
for i in range(100):
    if l[i] == 0 and diff > abs(x-(i+1)):
        diff= abs(x-(i+1))
        ans=i+1

print(ans)
import numpy

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

nmap = [i for i in range(1, 101)]

for (i, v) in enumerate(pList):
  nmap[v-1] = 101

for (i, v) in enumerate(nmap):
  nmap[i] = abs(v-x)

ans = numpy.argmin(nmap) + 1
print(ans)
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x + i)
    sys.exit()
  if x + i not in lst:
    print(x + i)
    sys.exit()
X, N = map( int, input().split() )
if N > 0:
  P = sorted( list( map( int, input().split() ) ))
  ret = -1
  dis = 10 ** 18
  for i in range( 100, -100, -1 ):
    if i in P:
      continue
    if dis - abs( i - X ) >= 0:
      ret = i
      dis = abs( i - X )
else:
  ret = X
print( ret )
import numpy as np
X, N = map(int, input().split())
p_list = set([int(i) for i in input().split()])
set_all = set(np.arange(-101, 101))
ex_list = set_all-p_list
ex_list = list(ex_list)
diff_list = [np.abs(i-X) for i in ex_list]
min_index = np.argmin(diff_list)
print(ex_list[min_index])
import bisect
x,n = map(int, input().split())
if (n==0):
    print(x)
    exit()
p = list(map(int, input().split()))
a = []
for i in range(101):
    if (i in p):
        continue
    a.append(i)
#print(a)


z = bisect.bisect_left(a,x)
if (z==0):
    print(a[0])
    exit()
elif (z==len(a)):
    print(a[-1])
    exit()
a1 = a[z]
a2 = a[z-1]
if (abs(a1-x) < abs(a2-x)):
    print(a1)
else:
    print(a2)
x,n=map(int, input().split())
p=list(map(int, input().split()))

if p == []:
    print(x)
    exit()

tmp1 = x
tmp2 = x

for i in range(1,120):
    tmp1 = tmp1 - 1
    tmp2 = tmp2 + 1
    if tmp1 not in p:
        print(tmp1)
        exit()
    if tmp2 not in p: 
        print(tmp2)
        exit()
X, N = map( int, input().split() )
if N > 0:
  P = sorted( list( map( int, input().split() ) ))
  ret = -1
  dis = 10 ** 18
  for i in range( min( P ), max( P ) + 1 ):
    if i in P:
      continue
    if dis - abs( i - X ) > 0:
      ret = i
      dis = abs( i - X )
else:
  ret = X
print( ret )
X, N = map(int, input().split())
P = list(map(int, input().split()))

A = [0]*101
for i in P:
    A[i] = 1

if A[X] == 0:
    print(X)
    exit()

count = 1
while(1):
    if (X - count) < 101 and (X - count) >= 0:
        if A[X - count] == 0:
            print(X - count)
            exit()

    if count > 0:
        count = -count
    else:
        count = -count
        count += 1
def readInt():
    return list(map(int,input().split()))
    
x,n = readInt()
a = []
if 0<n<100:
    p = readInt()
    p_r = [int(i) for i in range(101) if i not in p]
    # print(p_r)
    for i in p_r:
        dif = abs(x-i)
        a.append(dif)
    # print(a)
    print(p_r[a.index(min(a))])
else:
    print(x)
X,N = map(int,input().split())

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

Ans = 400

for i in range(100):
    if max(0,X-i) in p:
        Ans = Ans
    else:
        Ans = max(0,X-i)
        break
    if min(101,X+i) in p:
        Ans=Ans
    else:
        Ans = min(100,X+i)
        break
print(Ans)
x,n = map(int,input().split())
if n == 0:
    print(x);exit(0)
*p, = sorted(map(int,input().split()))
pp = set(p)
ans = 9e9
for i in range(0,101):
    if i in pp: continue
    dis = abs(i-x)
    if dis < ans:
        xx = i
        ans = dis
    else:
        break
print(xx)
a,b=map(int, input().split())
if b == 0:
  c = []
  b = False
  print(a)
else:
  c=list(map(int, input().split())) 
  b = True
while b ==True:
  k = 1
  m = a+k
  n = a-k
  if (m & n) not in c:
    print(n)
    b = False
    break
  if n not in c:
    print(n)
    b = False
    break
  if m not in c:
    print(m)
    b = False
    break
  k += 1
X, N = map(int,input().split())

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

ans = 1

if N != 0 :
    for i in range(105):
        if p.count(i)==0 :
            if abs(X-i) < abs(X-ans) :
                ans = i
    if X <= abs(X-ans):
        ans = X
    print(ans)
else :
    print(X)
X,N = map(int,input().split())
P = list(map(int,input().split()))

result = 0
if N == 0:
    result = X
else:
    list = [i for i in range(-100,101)]
    for i in P:
        list.remove(i)
    min = 100
    for i in list:
        if min > abs(X-i):
            min = abs(X - i)
            result = i

print(result)
X, N = map(int, input().split())
if N>0:
  p = [int(i) for i in input().split()]
else:
  p = [-1]
  
p = sorted(p)

try:
  idx=p.index(X)
  for i in range(N):
    if idx-i<0:
      print(X-i)
      break
    elif idx+i>=N:
      print(idx, i)
      print(X+i)
      break
    elif X-i!=p[idx-i]:
      print(X-i)
      break
    elif X+i!=p[idx+i]:
      print(X+i)
      break
except:
  print(X)
x, n = map(int, input().split())
try:
	p_li = list(map(int, input().split()))
except:
	print(x)
	exit()

for i in range(1000):
	
	if not((x - i) in p_li):
		print(x - i)
		break
	
	if not((x - i) in p_li):
		print(x - i)
		break
X, N = map(int, input().split())
P = list(map(int, input().split()))

ans = X
if N==0:
    print(ans)
else:
    for n in range(1,100):
        if X-n >= 0 and X-n not in P:
            ans = X-n
            break
        elif X+n <= 100 and X+n not in P:
            ans = X+n
            break
    print(ans)
a, b = map(int, input().split())
list2 = set(map(int, input().split()))
list1=list(range(101))
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_lst = list(map(int, input().split()))
o_lst = list(range(0,102))
lst = list(set(p_lst) ^ set(o_lst))

if X in lst:
    print(X)
else:
    for i in range(len(lst)):
        if X - i in lst:
            print(X-i)
            break
        if X + i in lst:
            print(X+i)
            break
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(n+1,1,-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())

try:
    p = list(map(int, input().split()))
except EOFError:
    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()
P = list(map(int, input(). split()))

for n in range(1, (N // 1) + 1):
    if not (X - n) in P:
        print(X - n)
        exit()
    if not (X + n) in P:
        print(X + n)
        exit()
print(min(P) - 1)
import numpy as np
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
set_p = set(p)

if X not in set_p:
    print(X)
else:
    tmp = set(range(1, 101))
    notinp = np.array(list(tmp - set_p))
    if len(notinp) == 0:
        print(0)
    else:
        t = np.abs(np.array(notinp) - X)
        argmin = t.argmin()
        print(notinp[notinp == notinp[argmin]].min())