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:
    l = list(map(int, input().split()))
    tmp = x
    i = 1
    while i:
        if not x in l:
            print(x)
            break
        elif not tmp in l:
            print(tmp)
            break
        x -= 1
        tmp += 1

Solution (Python):
x,n=map(int, input().split())
ans=x
judge=True
if(n!=0):
  p=list(map(int, input().split()))
else:
  ans=x
  judge=False
  
if(n==1):
  if(x==p[0]):
    ans = x-1
    judge=False

if(judge):
  check=True
  s_list=[]
  l_list=[]
  for i in range(n):
    for j in range(n):
      if(x-i==p[j]):
        check=False
    if(check):
      s_list.append(x-i)
    check=True

    for i in range(n):
      for j in range(n):
        if(x+i==p[j]):
          check=False
      if(check):
        l_list.append(x+i)
      check=True
    if(l_list == []):
      ans = max(s_list)
    if(s_list == []):
      ans = min(l_list)
    else:
      if(abs(x-min(l_list)) > abs(x-max(s_list))):
        ans = max(s_list)
      elif(abs(x-min(l_list))==abs(x-max(s_list))):
        ans=max(s_list)
      else:
        ans=min(l_list)  

print(ans)

Solution (Python):
x, n = map(int, input().split())
P = list(map(int, input().split()))
if not P:
    print(x)
    exit(0)
for i in range(x, 102):
    if i not in P:
        upper = i
        break
    else:
        upper = 102
for i in range(x, -1, -1):
    if i not in P:
        lower = i
        break
    else:
        lower = 0
print(lower if x-lower <= upper - x else upper)

Solution (Python):
X,N = map(int,input().split())
p = list(map(int, 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 = [int(i) for i in input().split(' ')]

if n:
    p = [int(i) for i in input().split(' ')]
    if x in p:
        for i in range(1, 101):
            if not x - i in p:
                print(x - i)
                exit()
            elif not x + i in p:
                print(x + i)
                exit()
    else:
        print(x)
else:
    print(x)

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, 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()))
 
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())
retsu = list(map(int, input().split()))



hanbetsu = []
for i in range(102):
    hanbetsu.append(i)

retsu = set(retsu)
hanbetsu = set(hanbetsu)
hikaku = hanbetsu.difference(retsu)

if X in hikaku:
    print(X)
else:
    for i in range(1,101):
        if X - i in hikaku:
            print(X-i)
            break
        elif X + i in hikaku:
            print(X+i)
            break

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

P.sort()
ans = 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):
def search_near(X, N, nums):
    for n in range(1,N+2):
        if n % 2 ==0:
            diff = n//2 *(-1)
        else:
            diff = n//2
        target = X+diff
        if target in nums:
            pass
        else:
            print(target)
            break

X, N = map(int, input().split(" "))
if N ==0:
    print(X)
else:
    nums = [i for i in map(int, input().split(" "))]
    search_near(X,N,nums)

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

for i in range(200):
    a=x-i
    if a not in p:
        print(a)
        exit()
    a=x+i
    if a not in p:
        print(a)
        exit()

Solution (Python):
a=list(map(int,input().split()))
try:
  b=list(map(int,input().split()))
  out=-1
  for i in range(102):
    if i in b:
      continue
    if abs(out-a[0])>abs(i-a[0]):
      out=i
  print(out)
except EOFError:
  print(a[0])

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

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

p = [int(i) for i in input().split()]
  
q = set(range(102)) - set(p)  
  
r = sorted(q,key=lambda x:(abs(x-X),x))

print(r[0])

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

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

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

if X not in p:
  print(X)
  exit();

if N == 1 and p[0] == X:
  print(X-1)
  exit();

for j in range(101):
  if X-j not in p:
    print(X-j)
    exit();
  if X+j not in p:
    print(X+j)
    exit();

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
flag = [False] * 102
for value in p:
    flag[value] = True
minAbs = 200
for i in range(102):
    ab = abs(x - i)
    if not flag[i]:
        minAbs = min(minAbs, ab)
for i in range(102):
    ab = abs(x - i)
    if not flag[i] and ab == minAbs:
        print(i)
        break

Solution (Python):
import sys

def Forbidden_List(x,n,p):
  for i in range(n//2 + n%2 + 1):
    if x - i not in p: 
        return x - i
    if x + i not in p:
        return x + i

if __name__ == '__main__':
    input = sys.stdin.readline
    
    inp1 = input().rstrip().split()
    x,n = int(inp1[0]),int(inp1[1])
    if n == 0:
        print(x)
    else: 
        inp2 = input().rstrip().split()
        p = list(map(int,inp2))
        print(Forbidden_List(x,n,p))

Solution (Python):
import sys

def Forbidden_List(x,n,p):
  for i in range(n):
    if x - i not in p: 
        return x - i
    if x + i not in p:
        return x + i
  return x - n

if __name__ == '__main__':
    input = sys.stdin.readline
    
    inp1 = input().rstrip().split()
    x,n = int(inp1[0]),int(inp1[1])
    if n == 0:
        print(x)
    else: 
        inp2 = input().rstrip().split()
        p = list(map(int,inp2))
        print(Forbidden_List(x,n,p))

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

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

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

if n==0:
  print(x);exit()
  
if not x in Q:
  print(x) ; exit()

A=[]
for i in range(1,250):
  A.append(-i)
  A.append(i)
  
for i in A:
  if not x+i in Q:
    print(x+i)
    exit()

Solution (Python):

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

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

    min_list = []
    
    for i in range(-200, 200):
        if i not in p:
            ans = abs(i-x)
            min_list.append(ans)
    
    minimum = min(min_list)
    minimum_right = x + minimum
    minimum_left = x - minimum

    if minimum_right and minimum_left not in p:
        print(minimum_left)
    elif minimum_right not in p:
        print(minimum_right)
    else:
        print(minimum_left)

Solution (Python):
a,b = map(int,input().split())
lol = [int(n) for n in input().split()]
if(b == 0):
    print(a)
else:
    i = 0 
    while(1):
        if((a - i) not in lol):
            print(a-i)
            break
        elif((a + i) not in lol):
            print(a+i)
            break
        else:
            i += 1

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
ans = 0
for i in l-p:
    ans = min((abs(x-ans), ans), (abs(x-i), i))[1]
print(ans)

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

x,n = map(int,input().split())
L=list(map(int,input().split()))
if n==0:
    print(x)
    sys.exit()
if x not in L:
    print(x)
    sys.exit()
else:
    L.sort()
    for i in range(1,2*x):
        if x-i not in L:
            print(x-i)
            break
        if x+i not in L:
            print(x+i)
            break

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
ans = 0
for i in l-p:
    if abs(x-ans) > abs(x-i):
        ans = i
print(ans)

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
sa = 1000
ans = 0
for i in l-p:
    if sa > abs(x-i):
        sa = abs(x-i)
        ans = i
print(ans)

Solution (Python):
a, b= map(int, input().split())
lista= [int (x) for x in input().split()]

for i in range(102):
    if a-i not in lista:
        print(a-i)
        break
    elif a+i not in lista:
        print(a+i)
        break

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


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

Solution (Python):
a, b = map(int, input().split())
result = set(map(int, input().split()))

for i in range(200):
    if a-i not in result:
        print(a-i)
        exit()
    elif a+i not in result:
        print(a+i)
        exit()

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

Solution (Python):

import os
from sys import stdin
import bisect

def solve(tc):
    x, n = map(int, stdin.readline().split())
    if n==0:
        print(x)
        return

    seq = list(map(int, stdin.readline().split()))
    cand = list()
    for i in range(102):
        if i not in seq:
            cand.append(i)

    k = bisect.bisect_left(cand, x)
    ans = cand[k]
    if x-cand[k-1]<=cand[k]-x:
        ans = cand[k-1]
    print(ans)


tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Solution (Python):
def main():
    X, N = map(int, input().split())
    P = set(map(int, input().split()))
    for i in range(51):
        if X - i not in P:
            print(X-i)
            return
        if X + i not in P:
            print(X+i)
            return


if __name__ == "__main__":
    main()

Solution (Python):
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
P=set(P)
A=[]
for i in range(102):
    if i not in P:
        A.append(i)
zahyo=bisect.bisect_left(A,X)
ans=[]
ans.append([abs(X-A[zahyo]),A[zahyo]])
ans.append([abs(X-A[zahyo-1]),A[zahyo-1]])
ans.sort()
print(ans[0][1])

Solution (Python):
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
P=set(P)
A=[]
for i in range(110):
    if i not in P:
        A.append(i)
zahyo=bisect.bisect_left(A,X)
ans=[]
ans.append([abs(X-A[zahyo]),A[zahyo]])
ans.append([abs(X-A[zahyo-1]),A[zahyo-1]])
ans.sort()
print(ans[0][1])

Solution (Python):
x, n = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    a = [i for i in range(102)]
    for i in range(n):
        a[p[i]] = 0
    minimum = 100
    result = 100
    for i in reversed(range(102)):
            d = abs(x - a[i])
            if d <= minimum:
                minimum = d
                result = a[i]
    print(result)

Solution (Python):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
else:
  P = [int(x) for x in input().split()]  
  if X in P:
    i = 1
    while True:
      if (X-i in P) and (not X+i in P):
        print(X+i)
        exit()
      elif (not X-i in P) and (X+i in P):
        print(X-i)
        exit()
      elif (X-i in P) and (X+i in P):
        i+=1
      elif (not X-i in P) and (not X+i in P):
        print(X-i)
        exit()
  else:
    print(X)

Solution (Python):

import bisect

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

p_list = [0]*100

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

p_list = [0]+p_list+[0]

dis = 100
index = -1
for i, j in enumerate(p_list):
    if j == 1:
        continue
    
    if dis > abs(x-i):
        dis = abs(x-i)
        index = i
        

print(index)

Solution (Python):
X, N = [int(i) for i in input().split(" ")]

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

p = {int(i) for i in input().split(" ")}

all_p = {i for i in range(1000)}
ranges = all_p - p

diff = 1e9
for i in ranges:
    if diff > abs(i - X):
        diff = abs(i - X)

ans_1 = X + diff
ans_2 = X - diff

for i in ranges:
    if i == ans_2:
        print(ans_2)
        break
else:
    print(ans_1)

Solution (Python):

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

ans=x
if not x in pl:
    ans=x
else:
    for i in range(1,1000):
        x1=x+i
        x2=x-i
        if not x2 in pl:
            ans=x2
            break
        elif not x1 in pl:
            ans=x1
            break
print(ans)

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

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

def func(x, p):
    d = {}

    for i in range(len(p)):
        if p[i] not in d.keys():
            d[p[i]] = 1

    if x not in d.keys():
        return x

    p1 = x-1
    p2 = x+1

    odd = 1
    ans = 0

    while True:
        if odd == 1:
            if p1 not in d.keys():
                ans = p1
                break
            
            p1 -= 1
        else:
            if p2 not in d.keys():
                ans = p2
                break
            
            p2 += 1
        
        odd *= -1

    return ans

ans = func(x, p)
print(ans)

Solution (Python):
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x,n,*p = map(int,read().split())
nums=list(range(-1,102))
for a in p:
    nums.remove(a)
ans=min(nums,key=lambda y: (abs(y-x),y))
print(ans)

Solution (Python):
def solve(x,n,p):
    if x not in p:
        return x
    tmps = x-1
    tmpl = x+1
    while True:
        if tmps not in p:
            return tmps
        if tmpl not in p:
            return tmpl
        tmps -= 1
        tmpl += 1

    

if __name__ == '__main__':
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    print(solve(x,n,p))

Solution (Python):
X,N = map(int,input().split())
p = list(map(int,input().split()))
min = 100
pp = list(map(lambda x: x-X, p))
i = 0
f = 0
while f == 0:
    if not i in pp:
        res = X + i
        break
    if i >= 0:
        i = -1 * (i +1)
    else:
        i = -1 * i
print(res)

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

if N > 0:
    p = [int(x) for x in 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:
    print(X)

Solution (Python):
n,m=map(int,input().split())
d={int(x):True for x in input().split()}

temp=n
ans=0
while(True):
    if(temp not in d):
        ans=temp
        break
    temp+=1
temp=n
while(True):
    if(temp not in d):
        if(abs(n-temp)<=abs(n-ans)):
            ans=temp
        break
    temp-=1
print(ans)

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

if n == 0:
    print(x)
    quit()
p = set(map(int,input().split()))
dibba = 0
dif = float("inf")
for i in range(-100,201):
    if i not in p:
        diff = abs(x-i)
        if diff < dif:
            dif = diff
            dibba = i
print(dibba)

Solution (Python):
x, n = map(int, input().split())
P = list(map(int, input().split()))
diff, ans = 1000, -1
for i in range(0, 102):
    if (P.count(i)):
        continue
    if (abs(i - x) < diff):
        diff = abs(i - x)
        ans = i
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
    elif X + i not in p:
        print(X + i)
        break
    i += 1

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

Solution (Python):
X, N = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

i = 0

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

while (True):
    a = X + i
    b = X - i
    if b in P and a not in P:
        print(a)
        break
    if a in P and b not in P:
        print(b)
        break
    if a not in P and b not in P:
        print(b)
        break
    i += 1

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

d = 0
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())
L = list(map(int, input().split()))
i = 0
while True:
    if x-i not in L: print(x-i); break
    if i+x not in L: print(i+x); break
    i+=1

Solution (Python):
line = input().split()

num = int(line[0])
arrn = int(line[1])

if arrn==0:
  print(num)
  
else:
  arr = input().split()
  i = 1;
  
  if str(num) in arr:
    while True:
      
      left = num - i
      if str(left) in arr:
        print("",end="")
      else:
        print(left)
        break

      
      right = num + i
      if str(right) in arr:
        print("",end="")
      else:
        print(right)
        break

      i += 1
  else:
    print(num)

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

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

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

lp.sort()

distance = 0
try:
    idx = lp.index(x)
    while True:
        distance += 1
        dmin = x-distance
        dmax = x+distance
        if (idx-distance) < 0 or dmin != lp[idx-distance]:
            print(dmin)
            exit()
        if (idx+distance) >= len(lp) or  dmax != lp[idx+distance]:
            print(dmax)
            exit()
except ValueError:
    print(x)
    exit()

Solution (Python):
x, n = map(int, input().split())
a = set(map(int, input().split()))
print(min((i for i in range(102) if i not in a), key=lambda y:abs(x-y)))

Solution (Python):
x, n = map(int, input().split())
a = set(map(int, input().split()))
print(min([i for i in range(102) if i not in a], key=lambda y:abs(x-y)))

Solution (Python):
def main():
    
    s = [input().split() for l in range(2)]
    X, N, p, v = int(s[0][0]), int(s[0][1]), {int(x): int(x) for x in s[1]}, 0
    for i in range(0, 100, 1):
        if X - i not in p:
            v = abs(X - i)
            break
        elif X + i not in p:
            v = abs(X + i)
            break
    print(v)

if __name__ == '__main__':
    main()

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

import sys

if n==0:
  print(x)
  sys.exit()
  
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(0, 102) if i not in P]

ans = notP[0]
min_delta = abs(x - ans)

for p in notP:
  delta = abs(x - p)
  if delta<min_delta:
    ans = p
    min_delta = abs(x - ans)
    
print(ans)

Solution (Python):
import sys

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

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

idx = NL.index(X)
if NL[idx + 1] - X >= X - NL[idx-1]:
    print(NL[idx-1])
else:
    print(NL[idx+1])

Solution (Python):
x, n = list(map(int, input().split()))
if not n:
  print(x) 
else:
  l = list(map(int, input().split()))
  dic = {} 
  for ll in l: dic[ll] = 1
  i = 0
  while True:
    if not dic.get(x-i,0):
      print(x-i)
      break
    elif not dic.get(x+i, 0):
      print(x+i) 
      break
    i+=1

Solution (Python):

x, n = map(int, input().split())
ln = []
if n == 0:
  pass
else:
  ln = list(map(int, input().split()))
i = 0

while True:
    
    
    if (x-i in ln) == False:
        print(x-i)
        break
    elif (x+i in ln) == False:
        print(x+i)
        break  
    else:
        i +=1

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

def solve(x, n, seq):
    if n == 0:
        print(x)
        return

    lower = x - 1
    higher = x + 1

    seq_set = set()

    for i in range(n):
        current = seq[i]
        seq_set.add(current)
    
    
    while lower in seq_set and lower > 0:
        lower -= 1
    
    while higher in seq_set and higher <= 100:
        higher += 1
    
    lower_diff = abs(lower - x)
    higher_diff = abs(higher - x)

    if lower_diff and higher_diff > 1 and x not in seq_set:
        print(x)
    elif lower_diff <= higher_diff:
        print(lower)
    elif higher not in seq_set:
        print(higher)
    else:
        print(x)
    

solve(x,n,seq)

Solution (Python):
x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break

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

Solution (Python):
from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = []
if N != 0:
    num_list = [int(x) for x in stdin.readline().strip().split(" ")]


dec_num = X
inc_num = X
if N == 0:
    print(X)
elif X not in num_list:
    print(X)
else:
    while True:
        dec_num += -1
        inc_num += 1
        if dec_num not in num_list:
            print(dec_num)
            break
        if inc_num not in num_list:
            print(inc_num)
            break

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
for i in range(N // 2 + 3):
    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:
    p = list(map(int, input().split()))
    for i in range(N // 2 + 3):
        if X - i not in p:
            print(X - i)
            break
        if X + i not in p:
            print(X + i)
            break
else:
    print(X)

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()))
ans=105

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

Solution (Python):

x, n = map(int,input().split())
p = [int(i) for i in input().split()]

tmp = 2000
ans = 2000
for i in range(-50, 105):
    if not i in p:
        if tmp > abs(x - i):
            tmp = abs(x - i)
            ans = i
print(ans)

Solution (Python):
X,N = map(int,input().split())
A = [int(i) for i in input().split()]

ans = 0

for i in range(1,102):
  if i in A:
    pass
  else:
    if abs(ans - X) > abs(i-X):
      ans = i
print(ans)

Solution (Python):
x,y = map(int,input().split(" "))
if y == 0:
    print(x)
    exit()
ar = list(map(int,input().split(" ")))
if x not in ar:
    print(x)
else:
    a = x
    b = x
    while True:
        a -= 1
        if a not in ar:
            print(a)
            exit()
        b += 1
        if b not in ar:
            print(b)
            exit()

Solution (Python):
import bisect
num = []
X, N = map(int, input().split())

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

if len(num) > 0:
    num.sort()
    id = bisect.bisect_left(num, X)

    
    idDown = id
    down = X
    while (idDown >= 0) and (down == num[idDown]):
        down -= 1
        idDown -= 1

    idUp = id
    up = X
    while (idUp < N) and (up == num[idUp]):
        up += 1
        idUp += 1

    if (X - down) <= (up - X):
        print(down)
    else:
        print(up)

else:
    print(X)

Solution (Python):
x, n = map(int, input().split())
P = list(map(int, input().split()))
INF = 10**18
ans = INF
for i in range(-100, 102):
    if i in P:
        continue
    if ans > abs(x-i):
        ans = abs(x-i)
        cnt = i
print(cnt)

Solution (Python):
ma = lambda :map(int,input().split())
x,n = ma()
P = list(ma())
import collections
co = collections.Counter(P)
mi = -1
ab = 10**9
for i in range(-1,102):
    if abs(x-i) <ab:
        if co[i] >0:
            continue
        ab = abs(x-i)
        mi = i
print(mi)

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

d = 1001
for i in range(102):
    if i in p:
        continue
    if abs(x-i) < d:
        d = abs(x-i)
        ans = i
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    diff = INF
    ans = X if X not in s else None
    for i in range(-1, 102):
        if i in s:
            continue

        tmp = abs(X - i)
        if tmp < diff:
            diff = tmp
            ans = i

    print(ans)


if __name__ == "__main__":
    main()

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

if n == 0:
  print(x)
else:
  for i in range(0,102):
    
      if p.count(i) == 0:
        
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
          
  print(ans)

Solution (Python):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    x,n = map(int, input().split())
    p = list(map(int, input().split()))
    l = [abs(i-x) if i not in p else 103 for i in range(102)]

    ans = l.index(min(l))
    print(ans)
    
if __name__ == '__main__':
    main()

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

def main(X, N):
    if N == 0:
        return X
    arrp = [int(x) for x in input().split()]
    minus = X
    plus = X
    while True:
        if minus not in arrp:
            print(minus)
            exit()
        if plus not in arrp:
            print(plus)
            exit()
        minus -= 1
        plus += 1

print(main(X, N))

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


absp= list()
for i in p:
    absp.append(i-x)


absp = sorted(absp, key=abs)


uper, lower = 0, 0
while True:
    if not lower in absp:
        print(x+lower)
        exit()

    elif not uper in absp:
        print(x+uper)
        exit()

    uper += 1
    lower += -1

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

for diff in range(100):
    _x = x - diff
    if _x not in p:
        print(_x)
        exit()
    
    _x = x + diff
    if _x not in p:
        print(_x) 
        exit()

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

abs_min = int(1e5)
ans = -1
for i in range(0, 102):
    if i in a:
        continue
    if abs(x - i) < abs_min:
        abs_min = abs(x - i)
        ans = i
print(ans)

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

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

min=0
dev=200

for i in range(0,102):
  if i in p or abs(x-i)>=dev:
    continue
  dev=abs(x-i)
  min=i
print(min)

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

min_num = [300, abs(int(X) - 300)]

for a in range(0,102):
    A = abs(int(X) - a)
    
    if a in list:
        continue
        
    else:
        if A > min_num[1]:
            continue
            
        elif A == min_num[1]:
            min_num[0] = min(a,min_num[0])
            min_num[1] = abs(int(X) - min_num[0])
            
        elif A < min_num[1]:
            min_num[0] = a
            min_num[1] = abs(int(X) - min_num[0])
            
print(min_num[0])

Solution (Python):
x,n=map(int,input().split())
if n!=0:
  p=list(map(int,input().split()))
  p2=list(map(lambda s:s-x,p))
a=0
i=0
if n==0:
  print(x)
else:
  while a==0:
    if i in p2:
      if i==0:
        i=-1
      elif i>0:
        i=-1*(i+1)
      else:
        i=-1*i
    else:
      print(x+i)
      a=1
      break

Solution (Python):

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

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


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

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

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

if N == 0:
  ans = X
else:
  p = list(map(int, input().split()))
  ans = 0
  for i in range(200):
    if i in p:
      continue
    else:
      dis = i - X
      if dis < abs(ans - X):
        ans = i

print(ans)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 1000
applied = 1000
for i in range(-1,102):
    if i in p:
        pass
    else:
        dif = abs(x-i)
        if dif < ans:
            ans = dif
            applied = i
        else:
            pass
print(applied)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 1000
applied = 1000
for i in range(-100,102):
    if i in p:
        pass
    else:
        dif = abs(x-i)
        if dif < ans:
            ans = dif
            applied = i
        else:
            pass
print(applied)

Solution (Python):
a,b = map(int, input().split())
if b>0:
	p = list(map(int, input().split()))
else:
	print(a)
	exit()

n = a
m = a

for i in range(b+1):
	"""
	print(n)
	print(m)
	print("")
	"""
	if n in p:	
		n = n-1			
	else:

		print(n)
		exit()

	if m in p:		
		m = m+1
	else:
		print(m)
		exit()

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))
if n == 0:
    print(x)
else:
    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