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):
x,n=map(int,input().split())

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

    num=[1]*102
    count=1

    for i in p:
        num[i]=0   
    if num[x]==1:
        print(x)
    else:
        while True:
            if x-count>-1:
                if num[x-count]==1:
                    print(x-count)
                    break
            if x+count<103:
                if num[x+count]==1:
                    print(x+count)
                    break    
            count+=1

Solution (Python):
X,N=map(int,input().split())
p=list(map(int,input().split()))
diff=99
for x in range(102):
    if x not in p and abs(X-x)<diff:
        diff=abs(X-x)
        ans=x
print(ans)

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

for i in range(101):
  if X-i not in x:
    print(X-i)
    sys.exit()
  elif X+i not in x:
    print(X+i)
    sys.exit()

Solution (Python):
X,N=map(int,input().split())
p=list(map(int,input().split()))
diff=100
for x in range(102):
    if x not in p and abs(X-x)<diff:
        diff=abs(X-x)
        ans=x
print(ans)

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

    d = 1 << 30
    ans = -1
    for v in (0, 101):
        diff = abs(X - v)
        if d > diff or (d == diff and ans > v):
            d = diff
            ans = v

    for v in range(101):
        if v in P: continue
        diff = abs(X - v)
        if d > diff or (d == diff and ans > v):
            d = diff
            ans = v

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

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

ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Solution (Python):
X,N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  p = []
  
int_list = [i for i in range(102)]
forbidden_list = sorted(list(set(int_list) - set(p)))
num_X = int_list.index(X)
c = 10000000
 
if X in forbidden_list:
  print(X)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b >= a:
      print(forbidden_list[i - 1])
      break
    elif b < a:
      print(forbidden_list[i])
      break
  else:
    if a < b:
      print(forbidden_list[i])
    else:
      print(forbidden_list[i + 1])

Solution (Python):
x,N=map(int,input().split())
p=list(map(int,input().split()))
ans=101
if x in p:
    for i in range(102):
        if i in p:
            continue
        ans=min(ans,abs(i-x))
    if x-ans in p:
        ans*=-1
else:
    ans=0
print(x-ans)

Solution (Python):
def c_forbidden_list(RANGE=101):
    X, N = [int(i) for i in input().split()]
    P = set([int(i) for i in input().split()]) if N != 0 else set()

    for t in range(RANGE + 1):
        if X - t not in P:
            return X - t
        elif X + t not in P:
            return X + t
    return None  

print(c_forbidden_list())

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

table=[0]*102

for i in Ps:
    table[i]=1

ans=0
min=101
for i in range(0,102):
   if table[i]==0:
       temp=abs(x-i)
       if temp<min:
           min=temp
           ans=i

print(ans)

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

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



for i in range(101):
    if x -i not in p:
        print(x-i)
        exit()
    elif x +i not in p:
        print(x+i)
        exit()

Solution (Python):
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ans=0
d=float('inf')
for i in range(102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

Solution (Python):
X,N = map(int,input().split())
l=list(map(int,input().split()))
if N==0:
    print(X)
else:
    for i in range(101):
        if  X-i not in l:
            print(X-i)
            exit()
        elif X+i not in l:
            print(X+i)
            exit()

Solution (Python):
def solution(X, N, P):
    if N <= 0 or X not in P:
        return X

    P.sort()
    diff = [abs(p - X) for p in P]
    X_idx = diff.index(0)
    left = sorted(diff[:X_idx])
    right = sorted(diff[X_idx+1:])

    for i in range(1, len(P) + 1):
        left = X - i
        right = X + i

        nearest_l = None
        nearest_r = None
        if left not in P:
            nearest_l = left
            break
        if right not in P:
            nearest_r = right
            break
    else:
        nearest_r = len(P) + 1
    if nearest_l and nearest_r:
        nearest = min(nearest_l, nearest_r)
    elif nearest_l is not None:
        nearest = nearest_l
    elif nearest_r is not None:
        nearest = nearest_r
    return nearest

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

print(solution(X, N, P))

Solution (Python):
import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def S(): return sys.stdin.readline().rstrip()

X,N = map(int,S().split())
p = LI()
p = sorted(p)

for i in range((N+1)//2+1):
    if not (X-i in p):
        print(X-i)
        exit()
    if not (X+i in p):
        print(X+i)
        exit()

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

for i in range(1000):
    if X-i not in arr:
        print(X-i)
        exit()
    if X+i not in arr:
        print(X+i)
        exit()

Solution (Python):
x,n=map(int,input().split())
if n==0:exit(print(x))
p=list(map(int,input().split()))
ans=-1
tmp=float("inf")
for i in range(0,102):
    if i in p:
        continue
    k=abs(i-x)
    if k<tmp:
        ans=i
        tmp=k
print(ans)

Solution (Python):
from sys import stdin




def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())

res=['Yes', 'No']


test_case=1
while test_case:
    test_case-=1

    v=[1]*110
    x, n=mi()
    for i in li():
        v[i]=0
    l=r=x
    while True:
        if v[l]:
            print(l)
            exit()
        elif v[r]:
            print(r)
            exit()
        l-=1
        r+=1

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

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

hanb = 0
hans = 0

for i in range(0,100):
    big = x + i
    sml = x - i
    
    if big not in p:
        hanb += 1

    if sml not in p:
        hans += 1

    if hanb == 1 or hans == 1:
        break

if hanb == 1 and hans == 1:
    print(sml)

elif hans == 1:
    print(sml)

else:
    print(big)

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

for i in range(101):
  if X-i not in P:
    print(X-i)
    exit()
  elif X+i not in P:
    print(X+i)
    exit()

Solution (Python):


import sys































def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    x, n = mi()
    s = set(lmi())

    dist = 0
    while True:
        if x - dist not in s:
            print(x - dist)
            exit()
        elif x + dist not in s:
            print(x + dist)
            exit()
        dist += 1


if __name__ == "__main__":
    main()

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
now = 1001001001
ans = -1
for i in range(102):
    if i in p:
        continue
    j = abs(i-x)
    if j<now:
        ans = i
        now = j
print(ans)

Solution (Python):
import sys

X,N=map(int,input().split())
if N==0:
	print(X)
	sys.exit()

p=list(map(int,input().split()))
n=[0]*(103)
for i in range(len(p)):
	n[p[i]+1]=1

d_min=1000
for j in range(103):
	if n[j]!=1:
		d=abs((X+1)-j)
		if d_min>d:
			d_min=d
			ans=j-1
print(ans)

Solution (Python):
X,N,*p = map(int,open(0).read().split())
dif = 100
ans = -1
for i in range(102):
    a = abs(X-i)
    if i in p:
        continue
    if  a < dif:
        dif = a
        ans = i
print(ans)

Solution (Python):
X,N = map(int,input().split())
 
p = list(map(int,input().split()))
 
import sys
for i in range(51):
 
    if X-i not in p:
        print (X-i)
        sys.exit()
    elif X+i not in p:
        print (X+i)
        sys.exit()

Solution (Python):
import bisect
x,n=map(int,input().split())
l=list(map(int,input().split()))
k=[0]*(102)
for i in l:
    k[i]=1
s=10000
for i in range(102):
    if k[i]==1:
        continue
    if abs(x-i)<s:
        s=abs(x-i)
        ans=i
print(ans)

Solution (Python):
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))
ans=0
if y==0:
  print(x)
elif x not in nums:
  print(x)
else:
  for i in range(0,102):
    if i not in nums:
      if abs(x-i)<abs(x-ans):
        ans=i
  print(ans)

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

p = set(p)
for i in range(200):
    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 = list(map(int,input().split()))
 
import sys
for i in range(100):
 
    if X-i not in p:
        print (X-i)
        sys.exit()
    elif X+i not in p:
        print (X+i)
        sys.exit()

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
m=102
j=0
for i in range(0,102):
    if abs(x-i)<m and i not in p:
        m=abs(x-i)
        j=i
print(j)

Solution (Python):
X,N=list(map(int,input().split()))
if N>0:p=list(map(int,input().split()))
else:p=[]
memo=[False for i in range(105)]
for i in range(N):memo[p[i]]=True

riget,left=X+1,X-1
ans_r,ans_l=0,0

while(True):
    if memo[left]==False:
        ans_l=left
        break
    if memo[riget]==False:
        ans_r=riget
        break
    left-=1
    riget+=1

if N==0 or memo[X]==False:print(X)
elif abs(X-ans_r)>=abs(X-ans_l):print(ans_l)
else:print(ans_r)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int,input().split())]
ans = 100+100 
for d in range(100): 
    now_diff = abs(ans - x)
    min_x, max_x = x - d, x + d
    if min_x not in P:
        if now_diff > abs(min_x - x): ans = x-d
    elif max_x not in P:
        if now_diff > abs(max_x - x): ans = x+d
print(ans)

Solution (Python):
X,N = map(int,input().split())
 
p = list(map(int,input().split()))
 
import sys
for i in range(300):
 
    if X-i not in p:
        print (X-i)
        sys.exit()
    elif X+i not in p:
        print (X+i)
        sys.exit()

Solution (Python):
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

x, n = NextInts()
da = NextIntList()

ans = -1000

for i in range(200):
    if abs(ans-x) > abs(x-i) and not(i in da):
        ans = i

print(ans)

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

not_in_p = [i for i in range(0, 102) if i not in p]
nip_temp = list(map(lambda s: abs(x - s), not_in_p))

address = nip_temp.index(min(nip_temp))
print(not_in_p[address])

Solution (Python):
import sys

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

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

for i in range(N + 1):
    if p.count(X - i) == 0:
        print(X - i)
        sys.exit()
    elif p.count(X + i) == 0:
        print(X + i)
        sys.exit()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    sa = float("inf")

    ans = 0
    for i in range(-100, 102):
        if i in P:
            continue

        satmp = sa
        sa = min(sa, abs(i - X))
        if sa != satmp:
            ans = i

    print(ans)

    
    

if __name__ == '__main__':
    main()

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int,input().split())]

ans = 100000000 
for d in range(100): 
    now_diff = abs(ans - x)
    min_x, max_x = x - d, x + d
    if min_x not in P:
        if now_diff > abs(min_x - x): ans = x-d
    elif max_x not in P:
        if now_diff > abs(max_x - x): ans = x+d
print(ans)

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

Solution (Python):
def read_input(trans=int):
    return list(map(trans, input().split()))


X, N = read_input()
if N == 0:
    print(X)
else:
    list_p = read_input()

    for i in range(N+1):
        if X-i in list_p:
            if X+i in list_p:
                continue
            else:
                print(X+i)
                break
        else:
            print(X-i)
            break

Solution (Python):
def read_input(trans=int):
    return list(map(trans, input().split()))


X, N = read_input()
if N == 0:
    print(X)
else:
    list_p = read_input()

    for i in range(100):
        if X-i in list_p:
            if X+i in list_p:
                continue
            else:
                print(X+i)
                break
        else:
            print(X-i)
            break

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

for i in range(x, -1, -1):
  if not i in p:
    a1 = i
    break

for i in range(x, 100 + 2):
  if not i in p:
    a2 = i
    break

if x - a1 <= a2 - x:
  print(a1)
else:
  print(a2)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int,input().split())]

ans = 100000000 
for d in range(100+10):
    now_diff = abs(ans - x)
    min_x, max_x = x - d, x + d
    if min_x not in P:
        if now_diff > abs(min_x - x): ans = x-d
    elif max_x not in P:
        if now_diff > abs(max_x - x): ans = x+d
print(ans)

Solution (Python):
x, n = (int(x) for x in input().split())
p_list = list(map(int, input().split()))
 
ans = 0
 
max_ = 0
min_ = 0

for i in range(x, 102, 1) :
 
    if i not in p_list:
        max_ = i
        break
for j in reversed(range(x + 1)) :

 
    if j not in p_list:
        min_ = j
        break
 
if abs (min_ - x) <= abs(max_ - x) :
    ans = min_
else : 
    ans = max_
 
print(ans)

Solution (Python):
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  ans=x
else:
  ans=0
  for i in range(101):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
print(ans)

Solution (Python):
import numpy

import sys

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


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





for i in range(101):
    if x - i not in list:
        print(x - i)
        sys.exit()
    elif x + i not in list:
        print(x + i)
        sys.exit()

Solution (Python):
X,N=map(int,input().split())
p=list(map(int,input().split()))
diff=102
for x in range(102):
    if x not in p and abs(X-x)<diff:
        diff=abs(X-x)
        ans=x
print(ans)

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

ans=1000
for i in range(-105,102):
    if i in p:
        continue
    if abs(x-ans)>abs(i-x):
        ans=i
print(ans)

Solution (Python):
a,b=map(int,input().split())
if b!=0:
  B=list(map(int,input().split()))
  A=B.copy()
  for i in range(b):
    A[i]= abs(A[i]-a)
  A.sort()
  for i in range(A[-1]+2):
    if A.count(i)==1:
      if i!=0:
        if a-i in B:
          result=a+i
          break
        else:
          result=a-i
          break
    elif A.count(i)==0:
      result=a-i
      break
else:
  result=a
print(result)

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

Solution (Python):
def resolve():
	X, N = map(int, input().split())
	if N == 0:
		print(X)
	else:
		A = list(map(int, input().split()))

		for i in range(100):
			Y = X-i
			if Y not in A:
				print(Y)
				break
			Y = X+i
			if Y not in A:
				print(Y)
				break
resolve()

Solution (Python):
x, n = (int(x) for x in input().split())
p_list = list(map(int, input().split()))

ans = 0

max_ = 0
min_ = 0


for i in range(x, 102, 1) :

    
    

    if i not in p_list:
        
        max_ = i
        break


for j in reversed(range(x + 1)) :

    
    

    if j not in p_list:
        
        min_ = j
        break










if abs (min_ - x) <= abs(max_ - x) :
    ans = min_
else : 
    ans = max_

print(ans)

Solution (Python):
import sys
readline=sys.stdin.readline

X,N=map(int,readline().split())
P=set(list(map(int,readline().split())))

x = X
while x in P:
  x -= 1

minX = x

x = X
while x in P:
  x += 1
maxX = x

if abs(minX - X) <= abs(maxX - X):
  print(minX)
else:
  print(maxX)

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

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

Solution (Python):
X,N = map(int,input().split())
P = list(map(int,input().split()))+[float("inf")]
P.sort()
k = 0
ans = 1000
for i in range(-100,102):
    if i == P[k]:
        k += 1
        continue
    if abs(i - X) < abs(ans - X):
        ans = i
print(ans)

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

arr = []

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)
    min = x
    max = x

    for i in range(10000):

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break
                
        min -= 1
        max += 1

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

if N==0:
  print(X)

else:
  P = list(map(int,input().split()))
  if X not in P:
    print(X)
  
  else:
      a = X+1
      b = X-1
      
      while a in P:
        a+=1
      while b in P:
        b-=1
      
      if abs(X-a)<abs(X-b):
        print(a)
      else:
        print(b)

Solution (Python):
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
    print(ans)

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

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
print(min([i for i in range(0, 102) if i not in p],
          key=lambda i: (abs(X - i), i)))

Solution (Python):
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(-150, 200))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0]+x)

Solution (Python):
x, n = map(int, input().split())
minn = 10000000
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
for i in range(1000):
    if i not in p:
        tmp = abs(x-i)  
        if minn > tmp:
            ans = i
            minn = tmp
        elif minn == tmp:
            ans = min(i, ans)
print(ans)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
a = 0
ans = ''
while ans == '':
  if len(p) == 0:
    ans = x
  elif x - a not in p:
    ans = x - a
  elif x + a not in p:
    ans = x + a
  else:
    a += 1
print(ans)

Solution (Python):
import sys

(x, n) = map(int, sys.stdin.readline().strip().split())
list_input = list(map(int, input().split()))

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

for i in range(1, n+1):
    if x - i not in list_input:
        print(x-i)
        exit()
    elif x + i not in list_input:
        print(x+i)
        exit()

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

for i in range(101):
    if x-i not in p:
        print(x-i)
        exit()
    elif x+i not in p:
        print(x+i)
        exit()

Solution (Python):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit(0)

p = set(map(int,input().split()))
not_p = list(set(range(0,102)) - p)

minV = 101
ans = 0
for i in not_p:
    if abs(X - i) < minV:
        minV = abs(X - i)
        ans = i
print(ans)

Solution (Python):
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])

Solution (Python):
x,n=map(int,input().split())
P=set(map(int,input().split()))
d=float('inf')
ans=0
for i in range(102):
    if i in P:
        continue
    tmp=abs(x-i)
    if tmp<d:
        ans=i
        d=tmp
print(ans)

Solution (Python):
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])

Solution (Python):
import sys

def saiki(l,r,lst):
  if (l - 1) not in lst:
      return (l - 1)
  
  if (r + 1) not in lst:
      return (r + 1)
  
  return saiki(l - 1, r + 1, lst)

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

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

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

  if X not in arr:
    print(X)
    sys.exit()

  print(saiki(X,X,arr))

if __name__ == '__main__':
    main()

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

arr = []

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)

    for i in range(10000):

        if x - i not in arr:
            print(x - i)
            break

        if x + i not in arr:
            print(x + i)
            break

Solution (Python):
import numpy as np
X, N = list(map(int,input().split()))
if N == 0:
  print(X)
else:
  p_arr = list(map(int,input().split()))
  for i in range(101):
    if i == 0:
      if not (X in p_arr):
        print(X)
        break
    else:

      lower = (X-i in p_arr)
      upper = (X+i in p_arr)
      if not lower:
        print(X-i)
        break
      else:
        if not upper:
          print(X+i)
          break

Solution (Python):
x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
 
anskouho = []
if p:
    val = []
    for i in range(-200,200):
        if i not in p:
            anskouho.append(i)
    for i in anskouho:
        val.append(abs(x - i))
    if x - min(val) not in p:
        print(x - min(val))
    else:
        print(x + min(val))
else:
    print(x)

Solution (Python):
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    array = list(map(int, input().split()))
    answer = -114514
    for i in range(-200,200):
        ok = True
        for v in array:
            if v == i:
                ok = False
                break
        if ok is False:
            continue
        if abs(answer-X) > abs(i-X):
            answer = i
    print(answer)

Solution (Python):
import sys
X,N=list(map(int,input().split()))
P=list(map(int,input().split()))
if not X in P:
    print(X)
    sys.exit()
A=X
B=X
while True:
    A-=1
    B+=1
    if not A in P:
        print(A)
        sys.exit()
    if not B in P:
        print(B)
        sys.exit()

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
delta = 0
state_n = 0
state_p = 0
while True:
  ans_n = x - delta
  ans_p = x + delta
  for i in range(len(p)):
    if ans_n == p[i]:
      state_n = 1
    if ans_p == p[i]:
      state_p = 1
  if state_n == 0 and state_p == 0:
    ans = ans_n
    break
  if state_n == 1 and state_p == 1:
    state_n = 0
    state_p = 0
  elif state_p == 1:
    ans = ans_n
    break
  elif state_n == 1:
    ans = ans_p
    break
  delta = delta + 1

print(ans)

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

    min_num = sorted_p[0]
    max_num = sorted_p[-1]

    candidate_list = []
    no_flag = 0
    candidate_num = -1
    distance = 10000

    for cnt in range(0, 102):
        no_flag = 0
        for nums in range(n):
            if cnt == sorted_p[nums]:
                no_flag = 1

        if no_flag == 0:
            candidate_list.append(cnt)

    for cnt in range(len(candidate_list)):
        if abs(x - candidate_list[cnt]) < distance:
            candidate_num = candidate_list[cnt]
            distance = abs(x - candidate_num)

    print(candidate_num)

else:
    print(x)

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

P.sort()
ans = abs(10000000)
for i in range(-101, 102):
  if not i in P:
    ans = min(ans, abs(i-X))

if not X-ans in P:
  print(X-ans)
else:
  print(X+ans)

Solution (Python):
x,n = map(int, input().split())
if n==0:
  print(x)
else:
  p = list(map(int, input().split()))
  
  for i in range(101):
    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 = list(map(int, input().split()))
for i in range(0,101):
  if not (x - i in p):
    print(x - i)
    break
  elif not(x + i in p):
    print(x + i)
    break

Solution (Python):
k = list(map(int, input().split()))
if k[1] == 0:
  print(k[0])
else:
  l = list(map(int, input().split()))
  a = [i for i in range(102) if not i in l]
  m = []
  for i in a:
    m.append(abs(i - k[0]))
  print(a[m.index(min(m))])

Solution (Python):
if __name__=="__main__":
    
    X, N = map(int, (input().split(' ')))
    if N > 0:
        P = sorted(map(int, input().split(' ')))
        P_max = max(P)
        P_min = min(P)
        if X in P:
            for i in range(100):
                if (X-i) not in P:
                    print(X-i)
                    break

                elif (X+i) not in P:
                    print(X+i)
                    break
        elif X not in P:
            print(X)
    else:
        print(X)

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

Solution (Python):
def linked_merge_sort(l): 
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

x,n=map(int,input().split())
p=list(map(int,input().split()))
if x>50:
    ans = 101
else:
    ans = 0
for i in range(n):
    p[i]=p[i]-x
if n>1:
    linked_merge_sort(p)
    j=n-1
    for i in range(n):
        if p[i]>=0:
            j=i
            break
    for i in range(n):
        if j-i>=0:
            if p[j-i]!=-i:
                ans = x-i
                break
        elif j-i<0:
            ans=x+p[0]-1
            break
        if j+i<n:
            if p[j+i]!=i:
                ans = x+i
                break
        else:
            ans=x+p[n-1]+1
            break
elif n==1:
    if p[0]==0:
        ans=x-1
    else:
        ans=x
elif n==0:
    ans=x
print(ans)

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

ans = X

for i in range(N+1):
    a = X+i
    b = X-i
    if b not in p:
        ans = b
        break
    elif a not in p:
        ans = a
        break

print(ans)

Solution (Python):
X,N=map(int,input().split())
p=list(map(int,input().split()))
diff=102
for i in range(102):
    if i not in p and abs(X-i)<diff:
        diff=abs(X-i)
        ans=i
print(ans)

Solution (Python):

import sys
input = sys.stdin.readline
X,N = (int(i) for i in input().split())
if N !=0:
    p = list(map(int, input().split()))
elif N ==0:
    p=[-1]
p.sort()

ans =[]
for i in range(-1,102):
    if i not in p:
        ans.append((abs(i-X),i))
ans.sort()
print(ans[0][1])

Solution (Python):
def readInts():
 return list(map(int, input().split()))

def main():
  a = input()
  a =a.split(" ")
  x = int(a[0])
  n = int(a[1])
  if n == 0:
    print(x)
    return
    
  p = readInts()
  i= x 
  j = x + 1
  
  while i  in p:
    i -=1
    
  while j  in p:
    j += 1
 
  if abs(x-i) <= abs(x-j):
    print(i)
  else:
    print(j)
  
  
if __name__ == "__main__":
  main()

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
if x not in p:
    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