Problem:
 Score : 300 points    Problem Statement Given are an integer X and an integer sequence of length N : p_1, \ldots, p_N .  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X , that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.      Constraints  1 \leq X \leq 100  0 \leq N \leq 100  1 \leq p_i \leq 100  p_1, \ldots, p_N are all distinct.  All values in input are integers.         Input Input is given from Standard Input in the following format:  X  N  p_1  ...  p_N       Output Print the answer.        Sample Input 1 6 5
4 7 10 6 5      Sample Output 1 8  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the one nearest to 6 is 8 .       Sample Input 2 10 5
4 7 10 6 5      Sample Output 2 9  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the ones nearest to 10 are 9 and 11 . We should print the smaller one, 9 .       Sample Input 3 100 0      Sample Output 3 100  When N = 0 , the second line in the input will be empty. Also, as seen here, X itself can be the answer.

Solution (Python):
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:
    i = 1
    while i <= n:
        if a.count(i) == 2:
            i += 1
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        if x > 0:
            print(x-i)
        else:
            print(x+i)
        break

Solution (Python):
x,n = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    hoge = [i for i in range(x - n, x + n + 1)]
    sabun = list(set(hoge) - set(p))
    min_ = 300
    index_ = 0
    for i, v in enumerate(sabun):
        if abs(x - v) < min_:
            min_ = abs(x - v)
            index_ = i
    print(sabun[index_])

Solution (Python):
import bisect as bi

if __name__ == '__main__':

    x,n = map(int,input().split())
    A = list(map(int,input().split()))
    B = [i for i in range(102)]
    
    
    C = list(set(B) - set(A))

    
    ind = bi.bisect_left(C,x)

    if ind == 0:
        print(C[0])
    elif ind == x - n:
        print(C[ind])
    else:
        tmp_l = abs(C[ind-1] - x)
        tmp_r = abs(C[ind] - x)
        if tmp_l > tmp_r:
            print(C[ind])
        else:
            print(C[ind-1])

Solution (Python):
x,n=map(int,input().split())
p=set(map(int,input().split()))

low=x
high=x
while True:
  if low not in p:
    print(low)
    break
  elif high not in p:
    print(high)
    break
  low-=1
  high+=1

Solution (Python):
X,N=map(int,input().split())
alist = list(map(int, input().split()))
for a in range(X+1):
    for b in [-1,+1]:
        c = X + a * b
        if alist.count(c) == 0:
            print(c)
            exit(0)

Solution (Python):
x,n =map(int,input().split())
if n ==0:
    print(x)
    exit()
p =list(map(int,input().split()))
l = []
for i in range(51):
    if x-i not in p and x+i not in p:
        print(min(x-i,x+i))
        exit()
    elif x-i not in p and x+i in p:
        print(x-i)
        exit()
    elif x-i in p and x+i not in p:
        print(x+i)
        exit()

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

def calc(a):
    return abs(a - x)

if not n:
    print(x)
    exit()

l = [i for i in range(102) if i not in set(p)]
print(min(l, key=calc))

Solution (Python):
import bisect
import collections

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

def calc(a):
    return abs(a - x)

if not n:
    print(x)
    exit()

l = [i for i in range(102) if i not in set(p)]
print(min(l, key=calc))

Solution (Python):
x, n = map(int, input().split())
if n != 0:
    l = list(map(int, input().split()))
else:
    l = []

diff = 10**10
ans = 10**10

for i in range(102):
    if i in l:
        continue
    else:
        if abs(x-i) < diff:
            ans = i
            diff = abs(x-i)

print(ans)

Solution (Python):
import numpy as np
def forbidden_list():
    X, N = map(int,input().split())
    p = list(map(int, input().split()))
    lis = np.array([1 for i in range(102)])
    lis[p] = 0
    index = X
    ma = 102 - X
    for i in range(max(X,ma)):
        if index - i >= 0 and lis[index-i]:
            print(index-i)
            break
        elif index + i <= 101 and lis[index + i]:
            print(index + i)
            break
    
forbidden_list()

Solution (Python):
x, n = map(int, input().split())
if n != 0:
    l = list(map(int, input().split()))
else:
    l = []

diff = 10**18
ans = 10**18

for i in range(-10000, 10000):
    if i in l:
        continue
    else:
        if abs(x-i) < diff:
            ans = i
            diff = abs(x-i)

print(ans)

Solution (Python):
X, N = map(int,input().split())
p_n = list(map(int,input().split()))

p = list(range(102))

for i in p_n:
    for j in range(len(p)):
        if p[j] == i:
            p.pop(j)
            break
            

p_X = list(map(lambda x: x - X, p))
p_abs = list(map(abs,p_X))

print(p[p_abs.index(min(p_abs))])

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))

low = x
high = x
while True:
    if low not in p:
        print(low)
        break
    elif high not in p:
        print(high)
        break
    low -= 1
    high += 1

Solution (Python):
import sys

X, N = map(int,input().split())
P = []
if N != 0:
  P = list(map(int,input().split()))

table = [True]*102

for i in range(N):
  table[P[i]] = False

ans = 1e18
dif = 1e18

for i in range(0,102):
  if table[i] == False:
    continue
  elif abs(i-X) > dif:
    continue
  elif abs(i-X) == dif:
    if i < ans:
      ans = i
      dif = abs(i-X)
  else:
    ans = i
    dif = abs(i-X)

print(ans)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    plist = list(map(int,input().split()))
    answer = 0
    diff = 0
    while answer == 0:
        if (x - diff) not in plist:
            answer = x - diff
            break
        elif (x + diff) not in plist:
            answer = x + diff
            break
        diff += 1
    print(answer)

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))

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

print(ans)

Solution (Python):
X, N = map(int,input().split())
p = {int(x) for x in input().split()}


ans = 0
i = 0

while True:
    tmp = X - i
    if tmp not in p:
        ans = tmp
        break
    tmp = X + i
    if tmp not in p:
        ans = tmp
        break
    i += 1
print(ans)

Solution (Python):
x, n = map(int, input().split())

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

    p = sorted(p)
    pn = len(p)
    for i in range(pn):
        if x not in p:
            ans = x
        else:
            for j in range(100):
                if (x + j) not in p:
                    ans_1 = x + j
                    break
            for j in range(100):
                if (x - j) not in p:
                    ans_2 = x - j
                    break
            if abs(ans_1 - x) >= abs(ans_2 - x):
                ans = ans_2
            else:
                ans = ans_1
    print(ans)

Solution (Python):
X,N = map(int,input().split())

min = 100

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

Solution (Python):
X,N = map(int,input().split())

min = 100

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

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
cnt = 0
i = 0
while 1:
    if x - i not in p:
        print(x - i)
        break
    elif x + i not in p:
        print(x+i)
        break
    else:
        i += 1

Solution (Python):
X,N = map(int,input().split())
p = list(map(int,input().split()))

for i in range(X+1):
  for j in [-1,1]:
    a = X + i*j
    if p.count(a) == 0:
      print(a)
      exit(0)

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]:
    a = X + s * d
    if p.count(a) == 0:
      print(a)
      exit(0)

Solution (Python):
x,n = map(int,input().split())
if n>0:
    p = list(map(int,input().split()))

    tmp = -100
    diff = 10000000
    for i in range(0,102):
        if abs(x-i)<diff and i not in p:
            tmp = i
            diff = abs(x-i)
            
    print(tmp)
else:
    print(x)

Solution (Python):
x, n = list(map(int, input().split()))
q = list(map(int, input().split()))
p = [i for i in range(0, 102) if i not in q]

for i in range(len(p)):
    if p[i] < x:
        continue
    
    break

if p[i] == x:
    print(p[i])
else:
    if p[i] - x < x - p[i - 1]:
        print(p[i])
    else:
        print(p[i - 1])

Solution (Python):
x, n = map(int, input().split())
l = list(map(int, input().split()))

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

x_a = x
for i in range(100):
    x -= 1
    x_a += 1
    if x not in l:
        print(x)
        exit()
    if x_a not in l:
        print(x_a)
        exit()

Solution (Python):


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

t = -100
a = [0]*300
for p in P:
    a[100+p-1] = 1

d = 0
while True:
    if a[100+x-1-d] == 0:
        t = x-d
        break
    elif a[100+x-1+d] == 0:
        t = x + d
        break
    else:
        d += 1

print(t)

Solution (Python):
X,N = map(int, input().split())
P = list(map(int, input().split()))

min = 51

for i in range(102):
    if i not in P and abs(X-i) < min:
        min = abs(X-i)
        ans = i

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Solution (Python):
X, N = map(int, input().split())
L = list(map(int, input().split()))

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

list = [0 for _ in range(len(L))]
for i in range(len(L)):
    list[i] = abs(X - L[i])
list = sorted(list)

if min(list) != 0:
    print(X)
    exit()
else:
    num = 1
    cnt = 0
    for i in range(1, len(list)):
        if list[i] != num:
            break
        cnt += 1
        if cnt == 2:
            cnt = 0
            num += 1
if cnt == 0:
    print(X - num)
else:
    if X + num in L:
        print(X - num)
    else:
        print(X + num)

Solution (Python):
x,n = map(int,input().split())

if n == 0:
  print(x)
else:
  p = set(map(int,input().split()))
  i = 0
  while True:
    x_p,x_n = x+i,x-i
    if not x_n in p:
      print(x_n)
      break
    if not x_p in p:
      print(x_p)
      break
    i += 1

Solution (Python):
def p_has_value_x(p:list, x:int):
  for item in p:
    if int(item) == x:
      return True
  return False

def solve(p: list, x:int) -> int:
  if not p_has_value_x(p, x):
    return x

  pos = 1
  while True:
    aim_value = x - pos
    if aim_value <= 0:
      return aim_value
    if not p_has_value_x(p, aim_value):
      return aim_value
    aim_value = x + pos
    if not p_has_value_x(p, aim_value):
      return aim_value
    pos += 1


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

if n == 0:
  print(x)
else:
  p = input().split()
  print(solve(p, x))

Solution (Python):
l = [int(x) for x in input().split()]
X, N = l[0], l[1]
p = [int(x) for x in input().split()]

delta = 0
while True:
    if not X - delta in p:
        print(X-delta)
        break
    if not X + delta in p:
        print(X + delta)
        break
    delta += 1

Solution (Python):
def retminabs(x,p):
    dif=0
    while True:
        if not x-dif in p:
            return x-dif
        elif not x+dif in p:
            return x+dif
        dif+=1
X,N=map(int,input().split())
P=list(map(int,input().split()))
print(retminabs(X,P))

Solution (Python):

def main():
    x, n = map(int, input().split(" "))
    p =[]
    dif = 1e2
    ans = 0
    l_a = [i for i in range(102)]
    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()

Solution (Python):
def resolve():
    X, N = list(map(int, input().split()))
    P = list(map(int, input().split()))
    ans = float("inf")
    for i in range(0, 102):
        if i in P:
            continue
        if abs(X-ans) > abs(X-i):
            ans = i
        elif abs(X-ans) == abs(X-i):
            ans = min(ans, i)
    print(ans)


if '__main__' == __name__:
    resolve()

Solution (Python):
x, n = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(x+1):
    for j in [-1, 1]:
        a = x + i * j
        if ps.count(a) == 0:
            print(a)
            exit()

Solution (Python):
X,N = map(int, input().split())
P = list(map(int, input().split()))

if len(P) == 0:
  print(X)
else:
  for i in range(0,10000):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

Solution (Python):
X,N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input().split()))
P.sort(reverse=True)

for i in range(105):
    if X - i not in P:
        print(X - i)
        break
    if X + i not in P:
        print(X + i)
        break

Solution (Python):
import numpy as np
X,N = map(int, input().split())


if N == 0:
  print(X)
else:
  ans_v = 102
  ans_idx = 0
  candidate = list(np.arange(0,102))
  p = list(map(int, input().split()))
  for i in range(N):
    candidate.remove(p[i])
  for i in range(len(candidate)):
    if ans_v > abs(X-candidate[i]):
      ans_v = abs(X-candidate[i])
      ans_idx = i
  print(candidate[ans_idx])

Solution (Python):
import numpy as np
X,N = map(int,input().split())

if N ==0:
    print(X)

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

    length =np.zeros(102)
    length =list(length)

    for i in range(len(length)):
        length[i]= abs(X-i)

    for i in range(N):
        length[p[i]]=1000

    ans = length.index(min(length))
    print(ans)

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

i = 0
while True:
    if x-i not in p:
        print(x-i)
        break
    if x+i not in p:
        print(x+i)
        break
    i += 1

Solution (Python):
x, n = map(int,input().split())
lst = list(map(int,input().split()))
i = 0
while True:
  if ((x - i) not in lst):
    print(x - i)
    break
  if ((x + i) not in lst):
    print(x + i)
    break
  i = i + 1

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
st = set(P)
for i in range(111):
    if not X - i in st:
        print(X - i)
        exit(0)
    if not X + i in st:
        print(X + i)
        exit(0)

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
st = set(P)
ans = 111
for i in range(111):
    if i in st:
        continue
    if abs(ans - X) > abs(i - X):
        ans = i
print(ans)

Solution (Python):
X,N=map(int, input().split())
p=list(map(int,input().split()))   
if N==0:
    print(X)
else:
    for k in range(0,51):
        if not X-k in p:
            print(X-k)
            break 
        elif not X+k in p:
            print(X+k)
            break

Solution (Python):
X, N = map(int, input().split())
p_list = list(map(int, input().split()))

if N == 0: 
   print(X)
else:
   for i in range(0,100):
       if not X-i in p_list:
           print(X-i)
           break
       elif not X+i in p_list:
           print(X+i)
           break

Solution (Python):
x, n = map(int, input().split())

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

p.sort()

for i in range(100):
    a = x-i
    b = x+i
    if a not in p:
        print(a)
        break
    
    if b not in p:
        print(b)
        break

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 9999999999
lists = []
if n == 0:
    print(x)
    exit()
for i in range(-1000, 1000):
    if not i in p:
        lists.append(i)
for i in lists:
    if ans > abs(x - i):
        ans = abs(x-i)
        m = i
print(m)

Solution (Python):
X, N = map(int, input().split())
P = set(map(int, input().split()))

d = 10 ** 9
ans = 0
for i in range(120):
    if (i in P):
        continue
    if (abs(X - i) < d):
        ans = i
        d = abs(X - i)
print(ans)

Solution (Python):
X,N = map(int, input().split())
P = set(map(int, input().split()))

d = 10**9
ans = 0
for i in range(120) :
    if(i in P) :
        continue
    if(abs(X-i) < d) :
        ans = i
        d = abs(X-i)
print(ans)

Solution (Python):
X, N = map(int, input().split())
if N > 0:
    P = set(map(int, input().split()))
else:
    P = set()

d = 0
while True:
    for sign in [-1, 1]:
        cand = X + sign * d
        if cand not in P:
            print(cand)
            exit()
    d += 1

Solution (Python):
X, Y = list(map(int, input().split()))
if Y == 0:
  print(X)
else:
  P = list(map(int, input().split()))
  num = 0
  for i in range(Y + 1):
    num = X - i
    if num not in P:
      print(num)
      break
    num = X + i
    if num not in P:
      print(num)
      break

Solution (Python):
import sys

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

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

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

if x not in p:
  print(x)

else:
  flag = True
  d = 0
  while flag == True:
    d += 1
    if x-d not in p:
      print(x-d)
      flag = False
    elif x+d not in p:
      print(x+d)
      flag = False

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 9999999999
lists = []
if n == 0:
    print(x)
    exit()
for i in range(-1000, 1000):
    if not i in p:
        lists.append(i)
for i in lists:
    if ans > abs(x - i):
        ans = abs(x-i)
        m = i

print(m)

Solution (Python):
x,n=map(int,input().split())
datap=[int(i) for i in input().split()]

for i in range(x-n-1,x+1,1):
    if i in datap:
        pass
    else:
        ansm=i

for j in range(x+n+1,x-1,-1):
    if j in datap:
        pass
    else:
        ansp=j

if x-ansm>ansp-x:
    print(ansp)
else:
    print(ansm)

Solution (Python):
X, N = map(int, input().split())
if N: p = list(map(int, input().split()))
else: print(X); exit()
length = 10**4+2
ans = -1
for i in range(-1,103):
  if length > abs(X - i) and i not in p:
    length = abs(X - i)
    ans = i
print(ans)

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))

Q = [q for q in range(-1, 102) if q not in P]  
ans = min(Q, key=lambda q: (abs(q - X), q))  
print(ans)

Solution (Python):
X,N = map(int,input().split())
if  N == 0:
  print(X)
  exit()
array = sorted(list(map(int,input().split())))
if not X in array:
  print(X)
  exit()  
else:
  for i in range(1,200):
    X_plus = X + i
    X_pull = X - i
    if not X_pull in array:
      print(X_pull)
      exit()
    if not X_plus in array:
      print(X_plus)
      exit()

Solution (Python):
x, n = map(int, input().split())
ok = [True for _ in range(102)]
for p in list(map(int, input().split())):
    ok[p] = False
left, right = 0, 0
while ok[x - left] is False:
    left += 1
while ok[x + right] is False:
    right += 1

if left <= right:
    print(x - left)
else:
    print(x + right)

Solution (Python):
import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-10 for i in range(121)]
  

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 100000
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

Solution (Python):
from sys import exit

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

Solution (Python):
from sys import exit

x, n = map(int, input().split())
p = list(map(int, input().split()))
for d in range(x+1): 
    for s in [-1, 1]:
        a = x + d*s
        if not a in p:
            print(a)
            exit()

Solution (Python):
x, n = map(int, input().split())
p = [int(i) for i in input().split()]
if n == 0:
    print(x)
else:
    under = over = x
    for num in range(x - min(p) + 2):
        if not (x - num in p):
            under = x - num
            break
    for num in range(max(p) - x + 2):
        if not (x + num in p):
            over = x + num
            break
    if x - under <= over - x:
        print(under)
    else:
        print(over)

Solution (Python):
x,n=map(int,input().split())
p=set(list(map(int,input().split())))

if x not in p :
    print(x)
    exit()
i=1
while True:
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()
    i+=1

Solution (Python):
x,n=map(int,input().split())
a=list(map(int,input().split()))

i=0

while True:
    if not x-i in a:
        print(x-i)
        break
    if not x+i in a:
        print(x+i)
        break
    i+=1

Solution (Python):
x,n=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
p.sort()
p_non=[]


for i in range(102):
    if i not in p:
        p_non.append(i)
p_non.sort()

zettaiti=1000000
ans=None
for i in p_non:
    if abs(i-x)<zettaiti:
        ans=i
        zettaiti=abs(i-x)

print(ans)

Solution (Python):
x, num_of_nums = map(int, input().split(' '))

if num_of_nums == 0:
    print(x)
    exit()
    
nums = set(map(int, input().split(' ')))

diff = 0

while True:
    n1 = x - diff
    n2 = x + diff

    if n1 not in nums:
        print(n1)
        break
    
    if n2 not in nums:
        print(n2)
        break
    
    diff += 1

Solution (Python):
x,n = map(int,input().split())
if n == 0:
  print(x)
else:
  p = list(map(int,input().split()))
  k = [i for i in range(-200,201)]
  for i in range(n):
    if p[i] in set(k):
      k.remove(p[i])
  minimum = 99999
  ans = 0
  for i in range(len(k)):
    if abs(k[i] - x )  < minimum :
      minimum = abs(k[i] - x)
      ans = k[i]
  print(ans)

Solution (Python):
X, N = map(int,input().split())
p = list(map(int,input().split()))
i = 0
while True:
  if not X - i in p:
    print(X - i)
    break
  if not X + i in p:
    print(X + i)
    break
  i += 1

Solution (Python):
X, N = list(map(int, input().split()))
if N!=0:
    P = set(list(map(int, input().split())))
else:
    print(X)
    exit(0)

dist = 100
r = None
for i in range(105, -1, -1):
    if not i in P and abs(X-i) <= dist:
        dist = abs(X-i)
        r = i

print(r)

Solution (Python):
def abc170_c_2():
    """
    もっとシンプルに考えると
    Xから-1、+1と順番に探索して、見つかったものをリターンすればOKなはず。
    ±0～99までを調べる？
    """
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        for i in range(100):
            for s in [-1, +1]:
                a = x + i * s
                if a not in p:
                    return a
    print(solve())

if __name__ == '__main__':
    abc170_c_2()

Solution (Python):
def abc170_c_0():
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        check_dict = {}

        for i in search_values:
            
            check_dict[i] = abs(x - i)

        return min(check_dict, key=check_dict.get)
    print(solve())

def abc170_c_1():
    """
    もうちょいコンパクトに書いてみる
    """
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        
        ans = min(search_values, key=lambda a: (abs(a - x), x))

        
        

        return ans

    print(solve())

if __name__ == '__main__':
    abc170_c_1()

Solution (Python):
def abc170_c_1():
    """
    もうちょいコンパクトに書いてみる
    """
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        ans = min(search_values, key=lambda a: abs(a - x))

        return ans
    
    print(solve())

if __name__ == '__main__':
    abc170_c_1()

Solution (Python):
def abc170_c():
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        check_dict = {}

        for i in search_values:
            
            check_dict[i] = abs(x - i)

        return min(check_dict, key=check_dict.get)
    print(solve())

if __name__ == '__main__':
    abc170_c()

Solution (Python):
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Solution (Python):
import sys
x,n = map(int,input().split())
p = list(map(int,input().split()))

if p.count(x) == 0:
    print(x)
else:
    for i in range(1,110):
        if p.count(x-i) == 0:
            print(x-i)
            sys.exit()
        elif p.count(x+i) == 0:
            print(x+i)
            sys.exit()

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = sorted(p)
new = []
t = x in l

if t == False:
    re = x 
else:
    for i in range(len(l)):
        TorF_1 = x + i + 1 in l
        TorF_2 = x - i - 1 in l
        if TorF_2 == False:
            re = x - i - 1
            break

        elif TorF_1 == False:
            re = x + i + 1
            break
    
print(re)

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))

ans = min(abs(x - i) for i in range(102) if i not in p)
print(x + ans if x - ans in p else x - ans)

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))

ans = 1000
ans = min(abs(x-i) for i in range(102) if i not in p)
print(x + ans if x - ans in p else x - ans)

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

ans=0
for i in range(102):
    if not i in p and abs(x-ans)>abs(x-i):
        ans=i
print(ans)

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))

ans = 1000
for i in range(102):
    if i not in p:
        ans = min(ans, abs(x - i))
print(x + ans if x - ans in p else x - ans)

Solution (Python):
X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  nums = list(map(int, input().split()))
  existed = [0 for _ in range(102)]
  for num in nums:
    existed[num] = 1
  for d in range(101):
    if 0 <= X-d <= 101 and existed[X-d] == 0:
      print(X-d)
      exit()
    if 0 <= X+d <= 101 and existed[X+d] == 0:
      print(X+d)
      exit()

Solution (Python):
x, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()] if n != 0 else []
min_ = 100
cnt = 0
for i in range(100 + 2):
  if abs(i - x) < min_ and not i in a:
    min_ = abs(i - x)
    cnt = i
print(cnt)

Solution (Python):
x, n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))
for i in range(100):
  if not x-i in p:
    print(x-i)
    break
  elif not x+i in p:
    print(x+i)
    break

Solution (Python):
x,n = map(int, input().split())
p = set(map(int, input().split()))
for i in range(101):
    if x-i not in p:
        print(x-i)
        break
    if x+i not in p:
        print(x+i)
        break

Solution (Python):
x,n = map(int, input().split())
p = set(map(int, input().split()))
for i in range(101):
    if x-i not in p:
        print(x-i)
        break
    if x+i not in p:
        print(x+i)
        break

Solution (Python):
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

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

ans = []
num = 0
while ans == []:
  if x + num in p and x - num in p:
    num+=1
  else:
    if x + num not in p and x - num not in p:
      ans = x - num
    elif x + num not in p:
      ans = x + num
    else:
      ans = x - num
print(ans)

Solution (Python):
X,N = map(int,input().split())
p = list(map(int, input().split()))

i = 0

if X not in p:
  print(X)

else:
  while True:
    i += 1
    if X - i not in p:
      print(X-i)
      break
    if X+i not in p:
      print(X+i)
      break

Solution (Python):
x,n=[int(x) for x in input().split()]
if n!=0:
    p=[int(x) for x in input().split()]
    l=list(range(110))
    for i in p:
        l.remove(i)
    L=[]
    for i in l:
        L.append(abs(i-x))
    m=min(L)
    print(l[L.index(m)])
else:
    print(x)

Solution (Python):
x,n=[int(x) for x in input().split()]
if n==0:
  print(x)
else:
  p=[int(x) for x in input().split()]
  ans=[]
  Flag=False
  while ans==[]:
    for i in range(105):
      if x-i not in p:
        ans.append(x-i)
        Flag=True
        break
      elif x+i not in p:
        ans.append(x+i)
        Flag=True
        break
    if Flag:
      break
  print(min(ans))