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)
  exit()
else:
  p = list(map(int, input().split(" ")))
  c = 0
  for i in range(200):
    if i+1 not in p:
      if abs(X-(i+1)) < abs(X-c):
        c = i+1
      else:
        print(c)
        exit()

Solution (Python):
import numpy as np

X, N = map(int, input().split())
if N == 0:
    p_list = [X]
else:
    p_list = np.array(list(map(int, input().split()))) - X
sorted_p_list = np.array(sorted(list(p_list)))
idx = np.abs(sorted_p_list).argmin()
p_list_kai = list(sorted_p_list)
tansaku_list = []
if p_list_kai[idx] == 0:
    hidari = idx - 1
    migi = idx + 1
    if hidari != -1:
        tansaku_list.append(p_list_kai[hidari])
    if migi != len(p_list_kai):
        tansaku_list.append(p_list_kai[migi])
    for i in range(1, 101):
        _i = i * (-1)
        if i in tansaku_list and _i in tansaku_list:
            migi += 1
            hidari -= 1
            if hidari != -1:
                tansaku_list.append(p_list_kai[hidari])
            if migi != len(p_list_kai):
                tansaku_list.append(p_list_kai[migi])
            continue
        elif i in tansaku_list:
            ans = X + _i
            break
        elif _i in tansaku_list:
            ans = X + i
            break
        else:
            ans = X + _i
            break
else:
    ans = X
print(ans)

Solution (Python):
temp1 = input().split(" ")
temp1 = [int(i) for i in temp1]
x = temp1[0]
n = temp1[1]

if not n == 0:
    temp2 = input().split(" ")
    temp2 = [int(i) for i in temp2]
else:
    temp2 = input()
    temp2 = []

pn = temp2

counter = 0
while True:
    if n == 0:
        print(x)
        break

    mx = x - counter
    px = x + counter

    if not mx in pn:
        print(mx)
        break
    if not px in pn:
        print(px)
        break

    counter += 1

Solution (Python):


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

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

an = [0]*105



for pi in pn:
    an[pi] = -1


dist = 10000
ans = 99999
for i, ai in enumerate(an):
    if ai == -1:
        continue

    if dist > abs(i-x):
        dist = abs(i-x)
        ans = i


print(ans)

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

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




D =[]

for j in range(100):
    xx = X + j
    if xx not in p:
        D.append(xx)
        break

for k in range(100):
    yy = X - k
    if yy not in p:
        D.append(yy)
        break



pura =abs(D[0]- X)
mai = abs(D[1]- X)

if mai <= pura:
    print(D[1])

else:
    print(D[0])

Solution (Python):
x,N = list(map(int,input().split(" ")))
if N != 0:
  p = list(map(int,input().split(" ")))
  sa = 0
  ans = -100
else:
  ans = x

while True:
  if ans != -100:
    break
  for i in range(N):
    if x-sa == p[i]:
      break
    if i == N-1:
      if x-sa != p[i]:
        ans = x-sa
  if ans != -100:
    break
  for i in range(N):
    if x+sa == p[i]:
      break
    if i == N-1:
      if x+sa != p[i]:
        ans = x+sa
  if ans != -100:
    break
  sa += 1
print(ans)

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

if n==0:
  print(x)
else:
  p=list(map(int , input().split()))
  con=0
  anco=0
  
  for _ in range(0, 100):
    for i in range(n):
      if x-_==p[i]:
        con=1
      if x+_==p[i]:
        anco=1
    if con==0:
        print(x-_)
        break
    elif anco==0:
      print(x+_)
      break
    con=0
    anco=0

Solution (Python):
from bisect import bisect_left
import sys
X,N=list(map(int,input().split()))
if N==0:
    print(X)
    sys.exit()
P=list(map(int,input().split()))
P=sorted(P)
x=bisect_left(P,X)
if x>=len(P):
    print(X)
    sys.exit()
if P[x]!=X:
    print(X)
    sys.exit()
A=X
B=X
while True:
    A-=1
    B+=1
    x1=bisect_left(P,A)
    x2=bisect_left(P,B)
    if x1<len(P) and P[x1]!=A:
        print(A)
        break
    if x2<len(P) and P[x2]!=B:
        print(B)
        break
    if x2==len(P):
        print(B)
        break

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

for i in range(n+1):
    count=0
    for j in range(n):
        if p[j]==x-i:
            count+=1
    if count==0:
        print(x-i)
        break
    count=0
    for j in range(n):
        if p[j]==x+i:
           count+=1
    if count==0:
        print(x+i)
        break

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

if N==0:
    print(X)
    sys.exit()
for i in range(101):
    ans = int(X)-i
    if str(ans) not in P:
        print(ans)
        break
    ans2 = int(X)+i
    if str(ans2) not in P:
        print(ans2)
        break

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

i=0
while i<=50:
    if X-i not in L:
        print(X-i)
        break
    elif X+i not in L:
        print(X+i)
        break
    else:
        i=i+1

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

cnt_plus=1
cnt_minus=-1

if x not in p:
    print(x)

else:
    
    while True:
        
        try:            
            
            if p[p.index(x)+cnt_plus] == x+cnt_plus:
                cnt_plus += 1
            
            else:
                plus_num = abs(x - (x+cnt_plus))
                break
        
        except IndexError:
            plus_num = abs(x - (x+cnt_plus))
            break           
    
    while True:
        try:
            
            if p[p.index(x)+cnt_minus] == x+cnt_minus:
                cnt_minus -= 1
                
            else:
                minus_num = abs(x - (x+cnt_minus))
                break
        
        except IndexError:
            minus_num = abs(x - (x+cnt_minus))
            break        
    if plus_num < minus_num:
        print(x+cnt_plus)
    else:
        print(x+cnt_minus)

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

a = []
for i in range(-100, 201, 1):
    a.append(i)

panda_set = set(a) ^ set(p)
panda = list(panda_set)
panda.sort()

ans = 1000
absolute = 1000
for num in panda:
    if(absolute > abs(X - num)):
        ans = num
        absolute = abs(X - num)

print(ans)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
	print(x)
else:
	p = list(map(int,input().split()))
	t = abs(min(p)-x)+1
	u = min(p)-1
	for i in range(min(x-1,min(p)-1),max(x+1,max(p)+2)):
		if not( i in p ):
			if abs(i-x)<t:
				t = abs(i-x)
				u = i
			elif  abs(i-x)==t:
				if i < u:
					u = i
	print(u)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
cnt = 0
jud1 = False
jud2 = False
while True:
    if not(x - cnt in p):
        s = x - cnt
        jud1 = True
    if not(x + cnt in p):
        o = x + cnt
        jud2 = True
    if jud1 == True or jud2 == True:
        break
    cnt += 1
if jud1 == True and jud2 == True:
    if s < o:
        print(s)
    else:
        print(o)
elif jud1 == True:
    print(s)
elif jud2 == True:
    print(o)

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

delta, notP = [], []
for i in range(0, 102):
    if not i in P:
        delta.append(abs(X-i))
        notP.append(i)

i = delta.index(min(delta))
print(notP[i])

Solution (Python):
int1, n_int = map(int, input().split())
diff = 1
if n_int == 0:
    print(int1)
else:
    list_num = [int(i) for i in input().split()]
    while True:
        if int1 not in list_num:
            print(int1)
            break
        else:
            num_check_minus = int1 - diff
            
            num_check_plus = int1 + diff
            
            
            if num_check_minus not in list_num:
                print(num_check_minus)
                break
            elif num_check_plus not in list_num:
                print(num_check_plus)
                break
            else:
                diff += 1

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

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

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul
import pprint



sys.setrecursionlimit(2147483647)
INF = 100
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


x, n = LI()
P = set(LI())
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):
x,n=map(int,input().split())
try:
  p=list(map(int,input().split()))
except:
  print(x)
  exit()
ans=float('inf')
for i in range(300):
  if i not in p:
    ans=min(ans,abs(x-i))
    
 
if x-ans not in p :
  print(x-ans)

else:
  print(x+ans)

Solution (Python):

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

Solution (Python):
def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if p == []:
        print(x)
    else:
        for i in range(0, 100):
            if not x-i in p:
                if x-i >= 0:
                    print(x-i)
                    break
            else:
                if not x+i in p:
                    if x+i <= 101:
                        print(x+i)
                        break
                    
if __name__ == '__main__':
    main()

Solution (Python):

p = []
cnt = 0
x, n = map(int, input().split())

p = input().split()

for i in range(n):
    p[i] = int(p[i])

while True:
    if not x in p:
        print(x)
        break
    if cnt % 2 == 0:
        x = x - (cnt + 1)
    elif cnt % 2 == 1:
        x = x + (cnt + 1)
    cnt += 1

Solution (Python):
XN = list(map(int, input().split()))
 
if XN[1] == 0:
  print(XN[0])
else:
  p = list(map(int, input().split()))
  for d in range(XN[1] + 1):
    if not XN[0] - d in p:
      print(XN[0] - d)
      break
    if not XN[0] + d in p:
      print(XN[0] + d)
      break

Solution (Python):
x, n = input().split()
x = int(x)
n = int(n)
m = list(map(int,input().split()))
sa = 999
ans = 0

if m.count(x) == 0 :
    print(x)
    exit()
elif len(m) == 0:
    print(x)
    exit()

for k in range(1,200):
    if m.count((x - k)) == 0 and x - (x - k) < sa:
        sa =  x - (x - k)
        ans = x - k

for l in range(1,200):
    if m.count((x + l)) == 0 and (x+l) - x < sa:
        sa = (x+l) - x
        ans = x + l

print(ans)

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

    for i in range(n):
        d[i]=x-int(a[i])



    for i in range(100):
        
        if not (i in d and i*-1 in d):
            if i in d:
                b= i + x
            else:
                b= x - i
        
        
        
            break

    print(b)

else:
    print(x)

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

s = set(p)
p = []
for x1 in range(-100, 200):
	if x1 in s:
		continue
	else:
		p.append(x1)
mind = abs(x - p[0])
pos = [p[0]]
for q in p:
	if abs(x - q) < mind:
		
		mind = abs(x - q)
		pos = [q]
	elif abs(x - q) == mind:
		pos.append(q)
pos.sort()
print(pos[0])

Solution (Python):
x, n = map(int, input().split())
if n != 0:
  n = list(map(int, input().split()))
  ans = []
  for i in range(101):
    if n.count(x + i) == 0:
      ans.append(x + i)

    if n.count(x - i) == 0:
      ans.append(x - i)
    
    if ans != []:
      break

  print(min(ans))
else:
  print(x)

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

i=0

while i<200:
    
    jud=1
    con=x-i

    for j in range(n):

        if con==p[j]:
            jud=0
            break

    if jud==1:
        print(con)
        break

    jud=1
    con=x+i

    for k in range(n):

        if con==p[k]:
            jud=0
            break

    if jud==1:
        print(con)
        break

    i+=1

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

if p == None:
    print(X)
else:
    for j in range(0,200):
        if (X-j) not in p:
            print(X-j)
            break
        elif (X+j) not in p:
            print(X+j)
            break

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


def f(X, N, listp):
    if N == 0:
        return X
    if X not in listp:
        return X

    index = listp.index(X)
    
    downres = 1000
    for i,p in enumerate(listp):
        if index - i >= 0:
            if listp[index-i] != X-i:
                downres = X-i
                break
    if downres == 1000:
        downres = X - index -1

    upres = 1000
    l = len(listp)
    for i,p in enumerate(listp):

        if index + i < l:
            if listp[index+i] != X+i:
                upres = X+i
                break
    if upres == 1000:
        upres = X + l - index

    if abs(upres - X) < abs(downres - X):
        return upres
    else:
        return downres


print(f(X, N, listp))

Solution (Python):
from sys import stdin,stdout
x,n=map(int,stdin.readline().split())
if n==0:print(x);exit(0)
s=set(map(int,stdin.readline().split()))
m1=m2=x
while 1:
    if m1 not in s:
        print(m1);exit(0)
    if m2 not in s:
        print(m2);exit(0)
    m1-=1
    m2+=1

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


for i in range(101):
    a = x + i
    b = x - i
    if b not in p:
        print(b)
        sys.exit()

    elif a not in p:
        print(a)
        sys.exit()

Solution (Python):
import numpy as np

a=[input() for i in range(2)]
a1=a[0].split()
a2=a[1].split()
x=int(a1[0])
n=int(a1[1])

p=[int(i) for i in a2]

d_list=[]

for i in np.arange(-1,102):
	if i not in p:
		d=abs(i-x)
		d_list.append(d)

sa=min(d_list)

an=x-sa
an2=x+sa

if an in p:
	print(an2)

else:
	print(an)

Solution (Python):
z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  l = []
  for i in range(-1, 102):
    l.append(i)
  for i in p:
    l.remove(i)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  print(ans)

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines




X, N = map(int, readline().split())

P = map(int, readline().split())

has = set()
for p in P:
    has.add(p)


ans = 0
for i in range(0, 102):
    if not i in has:
        if abs(X - i) < abs(X - ans):
            ans = i
print(ans)

Solution (Python):
def actual(X, N, P):
    for i in range(X, -1 - 1, -1):
        if i not in P:
            left = i
            break

    for i in range(X, 101 + 1):
        if i not in P:
            right = i
            break

    if abs(left - X) <= abs(right - X):
        answer = left
    else:
        answer = right

    return answer


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

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

Solution (Python):
import numpy as np
import sys
X, N = np.array(list(map(int, input().split())))
if N == 0:
    print(X)
    sys.exit()
p = np.array(list(map(int, input().split())))
p = np.sort(p)
a = np.ones(304, dtype = np.int)
a[p+102] = 0
m = X+1000
n = 0
for i in range(304):
    if a[i] == 1:
        if m>abs(i-X-102):
            m = abs(i-X-102)
            n = i-102
print(int(n))

Solution (Python):
x,n,*p = map(int,open(0).read().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):
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))





def solve():
	x, n = read();
	if n:
		arr = read()
	else:
		print(x)
		exit()
	t = x
	while t in arr:
		t -= 1
	s = x
	while s in arr:
		s += 1
	if abs(x-t) > abs(x-s):
		print(s)
	elif abs(x-t) == abs(x-s):
		print(t)
	else:
		print(t)







if __name__ == "__main__":
	solve()

Solution (Python):
x, n = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
if len(li) == 0:
    print(x)
    exit()
x1 = x
while x1 in li:
    x1 -= 1
x2 = x
while x2 in li:
    x2 += 1
if x-x1 > x2-x:
    print(x2)
else:
    print(x1)

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

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

P = [*map(int,input().split())]
P.sort()

D = set()
for i in range(n):
    D.add(abs(P[i]-x))





ans = 10000000000

if 0 in D:
    
    for d in range(100+10):
        if x-d not in P:
            
            
            if abs(ans-x) > abs((x-d)-x):
                ans = x-d
        elif x+d not in P:
            
            
            if abs(ans-x) > abs((x+d)-x):
                ans = x+d
else:
    ans = x
print(ans)

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

if N==0:
    print(X)
else:
    s=True
    num=0
    num1=0
    max=0
    min=0
    while s:
        if not X+num in List:
            max=X+num
            break
        num+=1
    while s:
        if not X-num1 in List:
            min=X-num1
            break
        num1+=1
    
    if max-X<X-min:
        print(max)
    if max-X> X-min:
        print(min)
    if max-X==X-min:
        print(min)

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

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

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

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


def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))
    assert N == len(p)
    if N == 0:
        print(X)
        exit()
    abs_list = []
    abs_list2 = list(range(-100, 100))
    abs_list2.sort()
    abs_list2 = sorted(abs_list2, key=abs)
    for i in p:
        abs_list.append(i-X)
    abs_list.sort()
    abs_list = sorted(abs_list, key=abs)
    
    
    for i in range(N):
        if abs_list[i] != abs_list2[i]:
            print(X+abs_list2[i])
            exit()
    print(X+abs_list2[N])


if __name__ == '__main__':
    main()

Solution (Python):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
else:
    p = set(map(int, input().split()))
q = set(range(min(p)-1,max(p)+2,1))
r = q - p
diff = 100
ans = 0
for i in r:
    if diff > abs(X-i):
        diff = abs(X-i)
        ans = i
print(ans)

Solution (Python):
X, N = list(map(int, input().split()))
if N == 0:
    print(X)
else:
    p = list(map(int, input().split()))
    not_p = set(range(-100, 110)) - set(p)

    arg_min = 10000
    value_min = 10000
    for i in not_p:
        tmp = abs(X - i)
        if tmp < value_min or (tmp == value_min and i < arg_min):
            value_min = tmp
            arg_min = i
    print(arg_min)

Solution (Python):
X,N=map(int,input().split())
if N == 0:
    print(X)
else:
    S=set(map(int,input().split()))
    L=list(S)
    L.sort()
    S0= set( [i for i in range(L[0]-1,L[N-1]+2)] )
    S1=list(S0-S)
    S1.sort()
    D=100
    for i in S1:
        if abs(i-X) < D:
            D=abs(i-X)
            ans = i
    print(ans)

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

L = [i-99 for i in range(202)]

for item in p:
    L.pop(L.index(item))
 
MIN = 10**5
ans = 10**5
for item in L:
    if abs(item-X) < MIN:
        MIN = abs(item-X)
        ans = item
 
print(ans)

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

antip = set(range(-110,210)) - set(p)
dist = 1000
ans = 1000
for v in antip:
    can = abs(v - X)
    if(can < dist):
        dist = can
        ans = v
    if(can == dist):
        ans = min(ans, v)
print(ans)

Solution (Python):
x,n = map(int,input().split())
li1 = list(map(int,input().split()))
if n == 0:
    print(x)
    exit()
b=100
c=0
li = []
li = list(range(min(li1)-1,max(li1)+2))
for ii in range(n):
    if li1[ii] in li:
        li.remove(li1[ii])
for i in range(len(li)):
    a=li[i]
    if a<=x:
        if b>x-a:
            b=x-a
            c=a
    else:
        if b>a-x:
            b=a-x
            c=a
print(c)

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

dist = 0
while True:
    if x - dist not in p:
        print(x - dist)
        break

    if x + dist not in p:
        print(x + dist)
        break

    dist += 1

Solution (Python):
a = list(map(int,input().split()))
x = a[0]
n = a[1]
if n>0:
  b = list(map(int,input().split()))
  c = list(range(-n,101+n))

  
  for i in range(n):
    if b[i] in c:
      c.remove(b[i])

  
  k = 1000
  kn = 0

  for i in range(len(c)):
    if k>abs(x-c[i]):
      k = x-c[i]
      kn = c[i]
  print(kn)
else:
  print(x)

Solution (Python):
kazulist = []
for i in range(-100,200):
    kazulist.append(i)
 
a = list(input().split(" "))
target = int(a[0])
syokyo = int(a[1])

if syokyo != 0:
    b = list(input().split(" "))
    for i in b:
        kazulist.remove(int(i))
 
saisyosa = 100
kotae = 0
for i in kazulist:
    sa = target - int(i)
    
    if sa < 0:
        sa *= -1
    if sa < saisyosa:
        saisyosa = sa
        kotae = i
 
print(kotae)

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

p.sort()
d = 10 ** 9
for i in range(-1000,1000):
    if d > abs(i-x) and i not in p:
        d = abs(i-x)
        ans = i
print(ans)

Solution (Python):


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

ans = 999
min = 999

if x not in p:
    ans = x
else:
    i = 1
    while min == 999:
        if x+i in p:
            i += 1
        else:
            min = i
            ans = x + i

    j = min
    while j != 0:
        if x-j not in p:
            ans = x - j
            j -= 1
        else:
            j -= 1

print(ans)

Solution (Python):
X,N=input().split();
X=int(X);
N=int(N);
if N==0:
  print(X);
  exit();
P=input().split();
P=[int(s) for s in P];


ans_min=X;
ans_max=X;
for i in range(210):
  x=X-i;
  if not x in P:
    
    ans_min=x;
    break;
for i in range(210):
  x=X+i;
  if not x in P:
    
    ans_max=x;
    break;

if abs(X-ans_min)<=abs(X-ans_max):
  print(ans_min);
else:
  print(ans_max);

Solution (Python):
import numpy as np
X, N = list(map(int,input().split()))
if N == 0:
  print(X)
else:
  P = list(map(int,input().split()))
  if P.count(X) == 0:
    print(X)
  else:
    L = list(np.arange(-1,102))
    for i in range(len(P)):
      L.remove(P[i])
    A = []
    for j in range(len(L)):
      A.append([abs(X-L[j]),L[j]])
    ans = 0
    for k in range(len(A)):
      if A[k][0]== min(A)[0]:
        ans = A[k][1]
        break
    print(ans)

Solution (Python):
import numpy as np

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

Solution (Python):
x, n = map(int,input().split())
if(n != 0):
    a = list(map(int, input().split()))
    if not x in a:
        print(x)
    else:    
        l = x
        r = x
        while(True):
            r += 1
            l -= 1
            if not l in a:
                print(l)
                break
            elif not r in a:
                print(r)
                break
else:
    print(x)

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

not_p_list = list(set(all_list)-set(p_list))
ans_list = []

if N == 0:
    print(X)
else:
    for i in not_p_list:
        j = abs(i - X)
        ans_list.append(j)

    

    ans = min(ans_list)
    minus_ans = -1 * ans

    

    if (minus_ans + X) in not_p_list:
        print(minus_ans + X)
    else:
        print(ans + X)

Solution (Python):


import sys
x, n = map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = input().split()
max_diff = 0
for i in p:
    max_diff = max(abs(x-int(i)),max_diff)
max_diff += 1
min_diff_int = 200
temp = 0
flag = False
for i in range(x-max_diff,x+max_diff+1):
    
    for j in p:
        if i == int(j):
            flag = True
            continue
    if flag:
        flag = False
        continue
    if min_diff_int > abs(x-i):
        min_diff_int = abs(x-i)
        temp = i
print(temp)

Solution (Python):
x_n = input()
x_n_list = x_n.split()
x = int(x_n_list[0])
n = int(x_n_list[1])
if n == 0:
  print(x)
else:
  allp = input()
  p_list = allp.split()
  p_l = [int(n) for n in p_list]
  if x not in p_l:
    print(x)
  else:
    for i in range(len(p_l)):
      if x - i - 1 not in p_l:
        print(x - i - 1)
        break
      elif x + i + 1 not in p_l:
        print(x + i + 1)
        break
      else:
        pass

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


base = list(range(-1, 100 + 2))

diff = list(set(base) - set(ls))

diff = sorted(diff)

ans = 1000
for i in diff:
    if abs(x - ans) > abs(x - i):
        ans = i

print(ans)

Solution (Python):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    pn = list(map(int, input().split()))
    is_ex_list = [False for i in range(max(pn) + 1)]
    for p in pn:
        is_ex_list[p] = True
    min_v = 101
    min_f = 101
    for i in range(-200, 201):
        if len(is_ex_list) > i and i >= 0:
            if not is_ex_list[i] and abs(x - i) < min_v:
                min_f = i 
                min_v = abs(x - i)
        elif abs(x - i) < min_v:
                min_f = i 
                min_v = abs(x - i)
    print(min_f)

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

p = set(p)
i=0
while i<101:
  n = X-i
  if not(n in p):
    ans = n
    break
  n = X+i
  if not(n in p):
    ans = n
    break
  i+=1

print(ans)

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

Solution (Python):
import numpy as np
X, N = (int(i) for i in input().split())
p = sorted([int(i) for i in input().split()])
if X in p:
    s = p.index(X)
    i = 1
    while True:
        if (s-i)<0:
            print(p[0]-1)
            break
        elif p[s-i] != (X-i):
            print(X-i)
            break
        elif (s+i)>=N:
            print(p[N-1]+1)
            break
        elif p[s+i] != (X+i):
            print(X+i)
            break
        else:
            i = i + 1
else:
    print(X)

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

x = int(line[0])
n = int(line[1])

line = input()
line = line.rstrip().split(' ')

p = []

for i in range(n):
    p.append(int(line[i]))
p.sort()

if  n == 0:
    print(x)
else:
    min = p[0] - 1
    max = p[-1] + 1
    answer = 1000
    for i in range(min, max + 1):
        if i in p:
            continue
        if abs(x - i) < abs(x - answer):
            answer = i

    print(answer)

Solution (Python):
a = input().split()
X = int(a[0])
N = int(a[1])
OK = []
list = []
if N ==0:
    print(X)
else:
    P = input().split()
    for i in range(102):
        OK.append(str(i))
    for i in range(len(P)):
        OK.remove(P[i])
    for i in range(len(OK)):
        list.append(abs(int(OK[i]) - X))
    Y = list.index(min(list))
    print(OK[Y])

Solution (Python):
X, N = map(int, input("").split(" "))
p = list(map(int,input().split()))
p.sort()
q = [i+1 for i in range(-2*X,2*X)]

ans = 0
diff = 100

for i in q:
    if (abs(X - i) < diff and (not i in p)):
        ans = i
        diff = abs(X-i)
print(ans)

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

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


exact=x
ansmin=x-1
ansmax=x+1

for i in range(n):
	if p[i]==exact:
		exact=200


	if p[i]==ansmax:
		ansmax+=1
		
p.sort(reverse=True)

for i in range(n):
	if p[i]==ansmin:
		ansmin-=1
	

	
if exact==x:
	print(exact)
elif abs(ansmax-x)<abs(ansmin-x):
	print(ansmax)
else:
	print(ansmin)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
if n != 0:
  p = sorted(map(int,input().split()))
aa = []
for i in range(1,101):
  if not i in p:
    aa.append(i)
bb = []
if len(aa) == 0:
  if abs(x-(0)) <= abs(x-101):
    print(0)
    exit()
  else:
    print(101)
    exit()
else:
  for A in aa:
    eee = abs(x-A)
    bb.append(eee)

ans = bb.index(min(bb))
if abs(x-(0)) <= min(bb):
  print(0)
  exit()
elif abs(x-101) < min(bb):
  print(101)
  exit()
else:
  print(aa[ans])
  exit()

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
ar1 = list(range(102))
ar2 = list(set(ar1) - set(p))
ar3 = sorted(ar2, reverse = True)
diff = 100
for i in ar3:
  if abs(x - i) <= diff:
    diff = abs(x - i)
    ans = i
  else:
    break

print(ans)

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

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

if X in P:
    for i in range(1,100):

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