peterverebics/CodeNet_Python_118 huggingface dataset:
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=100
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().strip().split())
list = []
list1 = []
if n==0:
    print(x)
else:
    dic = {}
    a = input().split()
    for i in range(0, len(a)):
        list.append(int(a[i]))
    for i in range(0, 100):
        b = abs(i - x)
        dic[i] = b
    min1 = min(dic, key=dic.get)
    i = 0
    for i in range(0, 101):
        if (list.__contains__(min1)):
            del dic[min1]
            min1 = min(dic, key=dic.get)
    print(min1)
x,n = map(int,input().split())
p = list(map(int,input().split()))

if n == 0:
    print(x)

else:
    i = 1
    while True:
        t = x-i
        s = x+i
        if t not in p:
            if t != 0:
                print(t)
                break
        if s not in p:
            print(s)
            break
        i +=1
x,length = map(int, input().split())
if length != 0:
  l = list(map(int, input().split()))
  l_b = list(range(1,100))
  diff = list(set(l) ^ set(l_b))
  sa = []
  for i in range(len(diff)):
    sa.append(abs(diff[i]-x))
  index = sa.index(min(sa))
  print(diff[index])
else:
  print(x)
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)
  for i in range(N):
    for o in [-1,+1]:
      idx2=idx+(i*o)
      #print(i, idx2, X+i*o, p[idx2])
      if idx2 < 0 or idx2 >= N or X+i*o!=p[idx2]:
        print(X+(i*o))     
        exit()

except ValueError:
  print(X)
x, n = map(int, input().split())
if n>0:
    p = list(map(int, input().split()))
else:
    print(x)
    exit()

kouho=[]

ans1=ans2=101
flag=0

for i in range(len(p)):
    if x+i not in p:
        ans1=x+i
        flag=1
    if x-i not in p:
        ans2=x-i
        flag=1
    if flag==1:
        break


# print(ans1,ans2)
print(min(ans1,ans2))
X, N = map(int, input().split())
d = list(map(int, input().split()))

for n in range(X + 1):
    for m in [-1, 1]:
        l = X + n*m
        if d.count(l) == 0:
            print(l)
            break
import sys

X,N = (int(a) for a in input().split())
p = list(map(int,input().split()))

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

for i in range(N) :
    if X not in p :
        print(int(X))
        sys.exit()
    else :
        X = X + (i+1)* ( (-1)**((i+1) ))
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])
  #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)
import numpy as np
X, N = map(int, input().split())
if N > 0:
  l1=list(map(int,input().split()))
else:
  l1=[]
ans = 100
l2 = np.array([i for i in range(1,101)])
l3 = set(l1) ^ set(l2)  
for item in l3:
  if ((X - item) ** 2) == ((X - ans) ** 2):
    if item < ans:
      ans = item
  elif  ((X - item) ** 2) < ((X - ans) ** 2):
    ans = item
print(ans)
x,n = map(int,input().split())
pl = list(map(int,input().split()))
for i in range(n):
  if not x-i in pl:
    print(x-i)
    exit()
  if not x+i in pl:
    print(x+i)
    exit()
X, Y = map(int, input().split())

if Y == 0:
    print(X)
if Y != 0:
    p = map(int, input().split())
    for i in range(1, 100):
        if X-i >= 1:
            if abs(X-i) not in p:
                print(X-i)
                break
        if X+i <= 100:
            if abs(X+i) not in p:
                print(X+i)
                break
def main():
    x, n = map(int, input().split(" "))
    p =[]
    dif = 1e2
    ans = 0
    l_a = [i for i in range(101)]
    if n != 0:
        p = list(map(int, input().split(" ")))
    for ele in l_a[::-1]:
        if abs(x - ele) <= dif and ele not in p:
            ans = ele
            dif = abs(x - ele)
    print(ans)
if __name__ == "__main__":
    main()
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))
p.sort()
ans = []
key = []

for i in range(0-max(p),max(p)+1):
  if i in p:
    continue
  else:
    #print(i)
    key.append(i)
    ans.append(abs(x-i))

aa = zip(ans,key)
aa = sorted(aa)
d,f = zip(*aa)
print(f[0])
xn=input().split()
x=int(xn[0])

data=input().split()
for i in range(100):
    for d in data:
        if int(d) == x-i:
            break
    else:
        print(x-i)
        break
    
    for d in data:
        if int(d) != x+i:
            break
    else:
        print(x+i)
        break
x,n = map(int,input().split())
p = list(map(int,input().split()))

for i in range(n+1):
    if x-i not in p:
        print(x-i)
        break
    elif x+i not in p:
        print(x+i)
        break
    else:
        continue
if not p:
    print(x)
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, -1, -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()))
if len(p)==0:
    print(x)

for i in range(x):
    a = x+i
    b = x-i
    if p.count(b)==0:
        print(b)
        exit()
    elif p.count(a)==0:
        print(a)
        exit()
def forbidden(x,p):
    res = []
    for num in range(101):
        if num not in p:
            if x!=num:
                res.append(abs(x-num))
    if x-min(res) not in p:
        return x-min(res)
    return x+min(res)

if __name__ == "__main__":
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    if n==0:
        print(x-1)
        exit()
    print(forbidden(x,p))
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ls.sort()
if n==0:
    print(x)
    exit(0)
else:
    ans=0
    d=1000000000
    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())
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//2+1):
    if idx-i<0:
      print(X-i)
      break
    elif idx+i>=N:
      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())
if n>0:
    p=list(map(int,input().split()))
    p=set(p)
    mini=10**10
    ans=0
    for i in range(101):
        if i not in p:
            if abs(i-x)<mini:
                mini=abs(i-x)
                ans=i
    print(ans)
else:
    print(x)
x,n = map(int,input().split())

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

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

for i in range(1,101):
    if i in p:
        continue
    s = min(abs(x-i),s)
        
if not x - s in p: 
    print(x - s)
else :
    print(x + s)
X, N = map(int, input().split())
P = [int(x) for x in input().split()]
cand = 1000
ans = -100
for t in range(-100, 101):
    if not(t in P):
        if abs(t-X) < cand:
            cand = abs(t-X)
            ans = t
print(ans)
x,n=map(int, input().split())
p=list(map(int, input().split()))

ans = x
diff = [0]*n

min_num = x
for i in range(101):
    if p.count(i) == 0:
        if min_num > abs(x-i):
            min_num = abs(x-i)
            ans = i

print(ans)
x, n = map(int, input().split())
p = list(map(int, input().split()))
sa = float("inf")
for i in range(1, 101):
    if i not in p:
        sa = min(sa, abs(i - x))
if x - sa not in p:
    print(x - sa)
else:
    print(x + sa)
x,n = map(int,input().split())
p = list(map(int,input().split()))

ne = [i for i in range(101) if i not in p]
a = []
ans = 100
for i in range(len(ne)):
    b = abs(ne[i]-x)
    if b < ans:
        a.append(ne[i])
        ans = min(b, ans)
print(a[-1])
x, n = map(int, input().split())
minn = 10000000
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))

for i in range(101):
    if not i in p:
        tmp = abs(x-i)
        if minn > tmp:
            ans = i
            minn = tmp
        elif minn == tmp:
            ans = min(i, ans)

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

if n == 0:
    ans = x
else:
    ans = float('inf')

d = float('inf')

for i in range(n+1):
    tmpx = x + 1 + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            if ans >= tmpx:
                ans = tmpx

print(ans)
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

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

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]
# print(minimum, maximum)

if X < minimum or maximum < X:
    print(X)
    exit()

answer = min(abs(X - minimum - 1), abs(X - maximum + 1))
for candidate in range(minimum, maximum):
    if candidate in p: continue

    diff_answer = abs(X - answer)
    diff_candidate = abs(X - candidate)
    # print(candidate, diff, answer)
    answer = candidate if diff_candidate < diff_answer else answer

print(answer)
def main():
    x, n = map(int, input().split())
    p = set(map(int, input().split()))
    if not x in p:
        print(x)
    else:
        a = [abs(i-x) if not i in p else 1000 for i in range(-1, 102)]
        print(a.index(min(a))+1)

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

ans = 300
for i in range(-200, 101):
    if i not in list:
        if abs(x-i) < abs(x-ans):
            ans = i

print(ans)
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
x, n  = map(int, input().split())
p  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

li = []
for i in range(1, 1001):
    if not i in p:
        li.append(i)

ans = 1000
min_ = 1000
for i, l in enumerate(li[::-1]):
    if min_ >= abs(x - l):
        min_ = abs(x - l)
        ans = l

print(ans)
x,n = map(int,input().split())
if n ==0:
  print(x)
  exit()
q = input().split()
p = sorted(abs(int(i)-x) for i in q)
for i in range(n):
    if i != p[i]:
        if x - i not in q:
            print(x - i)
        else:
            print(x + i)
        exit()
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 not in pset:
    print(X-i)
    break
lst = []
l = []
str = input()
l = str.split(' ')
n = int(l[0])
no = int(l[1])
if no==0:
  print(n)
 

else:  
  str1 = input()
  lst = str1.split(' ')
  for i in range(0,no):
    lst[i] = int(lst[i])
  for i in range(1,100):
    if n-i not in lst :
      print(n-i)
      break
    if n+i not in lst:
      print(n+i)
      break
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 )
x,n=map(int,input().split())
P=list(map(int,input().split()))

L=[]
for i in range(100):
    L.append(i+1)
for i in range(n):
    L.remove(P[i])

m=99

for i in range(len(L)):
    if abs(L[i]-x)<=m:
        m=abs(L[i]-x)

if n==0:
    print(x)
elif (x==1) and (1 not in L):
    print(0)
elif (x==100) and (99 not in L) and (100 not in L):
    print(101)
elif (x-m in L) or (x-m==0):
    print(x-m)
elif (x+m in L) or (x+m==101) :
    print(x+m)
x, n = map(int, input().split())
try:
  lst = list(map(int, input().split()))
except:
  lst = []
  
if x not in lst or lst == []:
  print(x)
else:
  for _ in range(1, 101):
    mx = max(x - _, 0)    
    mn = min(x + _, 100)
    if mx not in lst:
      print(mx)
      break
    elif mn not in lst:
      print(mn)
      break
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[];
if(fl!=[]):
    for a in lst:
         fl.append(int(a))
else:
    print(X)
for a in range(len(fl)):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break
import sys
X, N = map(int, input().split())
l = (int(i) for i in input().split())
if N == 0:
  print(X)

QUEUE = set()
def search(x):
  global QUEUE
  small = x - 1
  large = x + 1
  if small in QUEUE or large in QUEUE:
    return
  else:
    QUEUE.add(small)
    QUEUE.add(large)
    if not small in l:
      print(small)
      sys.exit(0)
    elif not large in l:
      print(large)
      sys.exit(0)
search(X)
x,n = map(int,input().split())
P = list(map(int,input().split()))

for i in range(101):
  xl = x - 1
  xr = x + 1
  if xl not in P:
    print(xl)
    break
  if xr not in P:
    print(xr)
    break
X,N=map(int, input().split())
p=list(map(int, input().split()))

if len(p)==0:
    print(X)
    exit()

for i in range(N):
    if p.count(X-i)==0:
        if X-i != 0:
            print(X-i)
            exit()
    if p.count(X+i)==0:
        print(X+i)
        exit()
x, n = map(int,input().split())
a = list(map(int, input().split()))
l = x
r = x
while(True):
    r += 1
    l -= 1
    if not l in a:
        print(l)
        break
    elif not r in a:
        print(r)
        break
X,N=map(int,input().split())
P=list(map(int,input().split()))
m=100
ans=0
lis=list(range(1,101))
for k in lis:
    for l in range(N):
        if k==P[l]:
            lis[k-1]=0
for i in lis:
    if abs(i-X)<m:
        m=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()))
t = list(range(1,101))
u = set(t)-set(p)
u = list(u)
dif = 2**60
ans = 0
if not u:
    print(0)
else:
    for a in u:
        if dif > abs(a-x):
            dif = abs(a-x)
            ans = a
        elif dif == abs(a-x):
            if ans > a:
                ans = a
    print(ans)
X, N = map(int, input().split())
p = input("").split(" ")
try:
    p = [int(i) for i in p]
    l = []
    for i in range(101):
        l.append(i)

    for i in range(N):
        if p[i] in l:
            l.remove(p[i])

    for i in range(101 - N):
        n = (X - l[i]) ** 2
        if n >= (X - l[i - 1]) ** 2:
            print(l[i-1])
            break
        else:
            pass
except(ValueError):
    print(X)
x,n=map(int,input().split())
if n == 0:
  print(x)
else:
  list=list(map(int,input().split()))
  i=1
  while i<1000:
    if not((x-i) in list):
      print(x-i)
      break
    if not((x+i) in list):
      print(x+i)
      break
    i+=1
X, N = map(int, input().split())
P = list(map(int, input().split()))

mi = 1000
ans = -1
for i in range(-1, 101):
    if i not in P:
        if mi > abs(X - i):
            mi = abs(X - i)
            ans = i
print(ans)
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
elif n == 100:
    print(0)
    exit()
p = list(map(int,input().split()))
t = list(range(1,101))
u = set(t)-set(p)
u = list(u)
u.sort()
dif = 2**60
ans = 2**60
for a in u:
    tmp = abs(a-x)
    if dif > tmp:
        ans = a
        dif = tmp
if x <= dif:
    ans = 0
print(ans)
a,b = map(int,input().split())
if(b != 0):
  c = list(map(int,input().split()))
else:
  print(a)
  exit()
ans = 0
for i in range(100):
  if(a+i not in c):
    if(a+i > 100):
      break
    else:
      ans = a+i
      break
for i in range(100):
  if(a-i not in c):
    if(a-i < 1):
      break
    else:
      if(abs(ans-(a-i)) < abs(a-ans)):
        ans = a-i
      elif(abs(ans-(a-i)) == abs(a-ans)):
        ans = min(a-i,ans)
      break
print(ans)
import numpy as np
X,N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  min_val = 0
  max_val = 101
  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]
  print(out_num)
else:
  print(0)
import numpy as np

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(-1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()
x,n = map(int,input().split())
seq = list(map(int,input().split()))
li=[]

if n==0:
  print(x)
else:
  back,front = x-1,x+1
  while back>=0 and front<=101:
    if back not in seq:
      print(back)
      break
    elif front not in seq:
      print(front)
      break
    else:
      back-=1
      front+=1
import sys
x,n=map(int,input().split())
if n==0:
  print(x)
  sys.exit()
p=list(map(int,input().split()))
jud=[0 for i in range(101)]
for i in p:
  jud[i]=1
if jud[x]==0:
  print(x)
  sys.exit()
diff=1
while 1:
  if x >= diff and jud[x-diff]==0:
    print(x-diff)
    break
  if x + diff < 101 and jud[x+diff]==0:
    print(x+diff)
    break
  diff+=1
X, N = map(int, input().split())
P = [int(x) for x in input().split()]
cand = 100
ans = 0
for t in range(-100, 101):
    if not(t in P):
        if cand > abs(t-X):
            cand = abs(t-X)
            ans = t
print(ans)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

X, N = MAP()
p = LIST()

ans = 0
min_num = float("INF")
for i in range(1, 101):
    if i in p:
        continue
    
    if min_num > abs(X-i):
        min_num = abs(X-i)
        ans = i


print(ans)
x,n = map(int, input().split())
if n==0:
  print(x)
else:
  p = list(map(int,input().split()))
  for i in range(1, 100):
    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())
lis = list(map(int,input().split()))
ans = 0
msf = 1000
for i in range(100,-1,-1):
    if i not in lis:
        diff = abs(i-x)
        if(min(diff,msf)==diff):
            msf = diff
            ans = i
print(ans)
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))

a = 100
b = 0
for i in range(0, 101):
    if i not in p and abs(x - i) < a:
        a = abs(x - i)
        b = i

print(b)
X, N = map(int, input().split())
nums = list(map(int, input().split()))

if N == 0:
    print(X)
else:
    for i in range(X):
        
        if X-i not in nums:
            print(X-i)
            exit()
        
        if X+i not in nums:
            print(X+i)
            exit()
x,n = map(int,input().split())
p = list(map(int,input().split()))
if n==0:
    print(x)
    exit()
a,b = x,x
while True:
    a+=1
    b-=1
    if b not in p:
        print(b)
        break
    elif a not in p:
        print(a)
        break
x,n = map(int,input().split())

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

num_list = list(map(int,input().split()))
i = 1

while True:
  if (x-i) not in num_list:
    print(x-i)
    break
  elif (x+i) not in num_list:
    print(x+i)
    break
  i += 1
X, N = map(int, input().split())
p = list(map(int, input().split()))
inv = list(set(list(range(1, 101))) - set(p))

min_num = float('inf')
min_diff = float('inf')

for i in inv:
    if abs(X - i) < min_diff:
        min_diff = abs(X - i)
        min_num = i

print(min_num)
X, N = map(int, input().split())
V_RANGE = 101

# 0~100
data_list = [i for i in range(V_RANGE)]
# 取得リスト
get_list = list(map(int, input().split()))

# (data_list-in_value)のリストを作る
sub_list = set(data_list) - set(get_list)

# 絶対値が最小のものを取得
g_abs = 10**4
abs_value = 0
for i in sub_list:
	t_abs = abs(X - i)

	if(g_abs > t_abs):
		g_abs = t_abs
		abs_value = i

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

mi = 101
ans=-1
for i in range(-1,101):
    if i in p:
        continue
    if abs(x-i) < mi:
        ans = i
        mi = abs(x-i)
print(ans)
# import math
# x, y = map(int, input().split())
# a = (4 * x - y) / 2
# if a >= 0 and a <= x and a == math.ceil(a):
#     print('Yes')
# else:
#     print('No')


x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
if n == 0:
    print(x)
for i in range(100):
    if x - i not in p:
        print(x - i)
        break
    if 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()))
  ans = []

  for i in range(n-2):
    if x-i not in p:
      ans.append(-i)
      break
    elif x+i not in p:
      ans.append(i)
      break
  if ans == []:
    ans.append(-3)

  print(x+ans[0])
x,n = map(int,input().split())
p = list(map(int,input().split()))

ne = [i for i in range(-200, 200) if i not in p]
a = []
ans = 100
for i in range(len(ne)):
    b = abs(ne[i]-x)
    if b <= ans:
        a.append(ne[i])
        ans = b
print(a[-1])
def resolve():
	X, N = map(int, input().split())
	if N == 0:
		print(X)
	else:
		A = list(map(int, input().split()))
		ymin = min(A)-1
		ymax = max(A)
		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 = list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort()
print(P)

l = [i for i in range(1, 101)]
l = list(set(l) - set(P))
print(l)

for i, v in enumerate(l):
    if v > X:
        print(l[i] if l[i]-X < X-l[i-1] else l[i-1])
        exit()

print(X)
X,N=map(int,input().split())
p=list(map(int,input().split()))
if N==0:
  print(X)
else:
  for i in range(0,X+1):
    if abs(X-i) not in p or abs(X+i) not in p:
      print(max([abs(X-i),abs(X+i)]))
      break
def main():
    x, n = map(int, input().split())
    p = set(map(int, input().split()))
    if not x in p:
        print(x)
    else:
        a = [abs(x-i) if not i in p else 1000 for i in range(-1, 102)]
        print(a)
        print(a.index(min(a))-1)

if __name__ == "__main__":
    main()
x, n = map(int, input().split())
p = list(map(int, input().split()))
result = []
for i in range(101):
    if i in p:
        continue
    else:
        result.append([abs(i-x), i])
result.sort()
print(result[0][1])
X, N =map(int, input().split())
p_list=list(map(int, input().split()))
#i=N
#1st Xがp_listにあるか
	#あれば+=!
	#なければ答え
#|X-i|=1がp_listにあるか
	#あれば+=!
	#なければ答え

i=N
j=0
while True:
	if X-j not in p_list:
		print(X+j)
		exit()
	elif X+j not in p_list:
		print(X-j)
		exit()
	else:
		j+=1
x,n=map(int,input().split())

sett=set(map(int,input().split()))
arr=[i for i in range(1,101) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)
x,n=map(int, input().split())
if n == 0:
  print(x)
  exit()
p=list(map(int, input().split()))
all=set(range(-100,101))
s_p=set(p)
kouho=sorted(all-s_p)

min_dis=201
for i in kouho:
  dis=abs(i-x)
  if min_dis > dis:
    min_i=i
    min_dis=dis
print(min_i)
x, n = [int(i) for i in input().split()]
ps = [int(i) for i in input().split()]

tmp = [(abs(i-x), i) for i in range(-100, 101) if i not in ps]
min_d = min(tmp, key=lambda x: x[0])[0]

ans = min(filter(lambda x: x[0] == min_d, tmp), key=lambda x:x[1])

print(ans[1])
x,n = map(int, input().split())
p = list(map(int, input().split()))
ans = 100
num = 0
for i in range(101):
    if i not in p:
        if abs(x - i) < ans:
            ans = abs(x - i)
            num = i
print (num)
#n = int(input())
x,n = map(int,input().split())
p_L = list(map(int,input().split()))

#p_L = list(sorted(p_L))
p_L = set(p_L)

sa = 101
for i in range(0,101):
    if i not in p_L:
        if sa > min(sa,abs(i-x)):
            sa = abs(x-i)
            ans = i
        #ans = min(i,)

print(ans)