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())
p = []
if N > 0:
  p = list(map(int, input().split()))
a = list(range(0, 111))
a = [item for item in a if item not in p]
res = a[0]
m = abs(res - X)
for i in a:
  j = abs(i - X)
  if j < m:
    m = j
    res = i
    
print(res)

Solution (Python):
X, N = map(int, input().split())
if N==0:
    print(X)
else:
    p = list(map(int, input().split()))
    
    for i in range(0,102):
        down = X - i
        up = X + i
        if down in p and up in p:
            pass
        elif down in p:
            temp = up
            break
        else:
            temp = down
            break



    print(temp)

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

for i in range(0, 102)[::-1]:
    if abs(x - i) <= min:
        if i not in p:
            min = abs(x - i)
            ans = i

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()))
lis = [i for i in range(102)]
for val in p:
    if val in lis:
        lis.remove(val)

d = {}
for i in lis:
    d[i] = abs(i - X)
ds = sorted(d.items(), key=lambda x: x[1])
print(ds[0][0])

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()]

num = list(range(102))
nums = []
for i in num:
  if not(i in p):
    nums.append(i)

p2 = [abs(nums[i]-x) for i in range(len(nums))]
p2min = min(p2)
for i in range(len(p2)):
  if p2[i] == p2min:
    print(nums[i])
    exit()

Solution (Python):
target, N = [int(x) for x in input().split(" ")]
if N == 0:
    print(target)
else:
    p_array = [int(x) for x in input().split(" ")]

    for i in range(N+1):
        superior = target - i
        if not(superior in p_array):
            print(superior)
            break

        inferior = target + i
        if not(inferior in p_array):
            print(inferior)
            break

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

      
  print(ans)

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

    for i in range(51):
        a = x - i
        b = x + i
        if a not in p and a >= 0:
            print(a)
            return
        if b not in p and b <= 101:
            print(b)
            return
    
        
if __name__ == '__main__':
    main()

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


if p == []:
    print(x)
    exit()

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

Solution (Python):
def main():
  
  

  
  

  
  
  
  if 'get_ipython' in globals(): 
    
    x, n = 6, 5
    P = [4, 7, 10, 6, 5]

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

  
  for i in range(1, 100):
    if x - i not in P:
        dif_mis = x-i
        break

  for i in range(0, 100):
    if x + i not in P:
        dif_pls = x+i
        break

  if (x-dif_mis)**2 > (x-dif_pls)**2:
    print(dif_pls)
  else:
    print(dif_mis)

main()

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

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

for diff in range(101):
    if (x - diff) not in p or (x + diff) not in p:
        if x - diff in p:
            print(x + diff)
            exit()
        print(x - diff)
        exit()

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

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

Solution (Python):
import numpy as np

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

num_list = list(set([*range(0,102)]) - set(p_list))

diff = np.abs(np.array(num_list)-X)
diff_arg_min = np.argmin(diff)

print(num_list[diff_arg_min])

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


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

if flist.count(X) == 0:
    print(X)
    exit()


l = list(range(0,102)) 


plist = []
for i in range(len(l)):
    if flist.count(l[i]) == 0:
        plist.append(l[i])


plist.append(X)
anslist = sorted(plist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] 
dist2 = anslist[t+1] - anslist[t] 
if dist1 <= dist2:
    print(anslist[t-1])
else:
    print(anslist[t+1])

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

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

    if x not in p:
        print(x)
    else:
        for i in range(1, 200):
            if x - i not in p:
                print(x - i)
                break
            if x + i not in p:
                print(x + i)
                break

if __name__ == '__main__':
    main()

Solution (Python):
x,y=map(int,input().split())
a=list(map(int,input().split()))
dif=1
if x not in a:
  print(x)
else:
  while True:
    if x-dif not in a:
      dif*=-1
      break
    elif x+dif not in a:
      break
    else:
      dif+=1
  print(x+dif)

Solution (Python):

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

if X not in p:
    print(X)
else:
    variable_val = 1
    while True:
        if X - variable_val not in p:
            print(X - variable_val)
            exit(0)
        if X + variable_val not in p:
            print(X + variable_val)
            exit(0)
        variable_val += 1

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):
import sys
input = sys.stdin.readline


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

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

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

Solution (Python):
from collections import defaultdict as dd
x, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = dd(int)
for i in a:
    d[i] = 1

left, right = x-1, x+1

if x not in d:
    print(x)
else:
    while(1):
        if left not in d:
            print(left)
            break
        if right not in d:
            print(right)
            break
        left -=1
        right +=1

Solution (Python):
"""A問題
x= list(map(int,input().split()))
a = 1
for i in x:
    if i == 0:
        print(a)
    a+=1
"""
"""B問題
[x,y]= list(map(int,input().split()))
if (y-2*x)%2==0 and y-2*x>=0 and 4*x-y>=0 :
    print("Yes")
else:
    print("No")
"""
[x,n]= list(map(int,input().split()))
p= list(map(int,input().split()))
q= [i for i in range(102)]
p= [i for i in q if i not in p]
r = [abs(i-x) for i in p]
print(p[r.index(min(r))])

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

p.sort()

if n == 0:
    print(x)
else:
    for i in range(0, 100):
        if (x-i) not in p:
            print(x-i)
            exit()
        if (x+i) not in p:
            print(x+i)
            exit()

Solution (Python):
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def bs(L, x):
	i, jump = 0, len(L)-1
	while jump >= 1:
		while i + jump < len(L) and L[i+jump] <= x:
			i += jump
		jump //= 2
	return i


def main():
	x, n = rli()
	P = list(rli())
	P.sort()
	forbidden = set(P)
	if x not in forbidden:
		print(x)
		return
	
	for diff in range(0, 101):
		a, b = x - diff, x + diff
		if a not in forbidden:
			print(a)
			return
		if b not in forbidden:
			print(b)
			return
	stdout.close()

if __name__ == "__main__":
	main()

Solution (Python):
x,n=map(int,input().split())
if n!=0:
  p=list(map(int,input().split()))
  hantei=10**9+1
  sp=set(p)
  ans=0
  for i in range(-10000,10000):
    if not i in sp:
      if hantei>abs(i-x):
        hantei=abs(i-x)
        ans=i
  print(ans)
else:
  print(x)

Solution (Python):
X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  plist = list(map(int,input().split()))
  ans = -2000
  dist1 = 1000
  for i in range(-200,200):
    dist2 = abs(X-i)
    if dist2 < dist1 and not(i in plist):
      ans = i
      dist1 = dist2
  print(ans)

Solution (Python):
import numpy as np
import sys
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

p.sort()

p0 = [0]
j = 0
for i in range(1,100):
    if p[j]!=i:
        p0.append(i)
    elif p[j] == i:
        j+=1
    if j == N:
        for i0 in range(i+1,100):
            p0.append(i0)
        break
p0.append(101)
p1 = [0 for i in range(len(p0))]
for i in range(len(p0)):
    p1[i] = p0[i]-X
    p1[i] = np.abs(p1[i])
    
ii = np.argmin(p1)

print(p0[ii])

Solution (Python):

def main():    
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    p = list(map(int, input().split()))
    check = 0
    while(1):
        s = check//2
        if check%2 == 0:
            ans = x-s
        else:
            ans = x+s
        if not ans in p:
            print(ans)
            return
        check += 1
main()

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

Solution (Python):
X, N = map(int, input().split())
arr = list(map(int, input().split()))
ans = 10000
for i in range(0,110):
    if i not in arr:
        if abs(X-i) < abs(X-ans):
            ans = i
print(ans)

Solution (Python):
x,y=map(int,input().split())
a=list(map(int,input().split()))
a=set(a)
for i in range(101):
  
  if x-i not in a:
        print(x-i)
        exit()
  elif x+i not in a:
      print(x+i)
      exit()

Solution (Python):
x,_,*l=map(int,open(0).read().split())
print(min((abs(i-x),i) for i in {*range(102)}-{*l})[1])

Solution (Python):
x,n,*l=map(int,open(0).read().split())
print(min((abs(i-x),i) for i in range(102) if i not in l)[1])

Solution (Python):
x,n,*l=map(int,open(0).read().split())
l=set(l)
t=101
for i in range(102):
  if i not in l and abs(i-x)<t: a,t=i,abs(i-x)
print(a)

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)
        exit()
    elif x+i not in p:
        print(x+i)
        exit()

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

def ok(n):
	if not n in a:
		print(n)
		exit()


for i in range(1000):
	ok(x-i)
	ok(x+i)

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

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

Solution (Python):
X, N=map(int, input().split())
a=list(map(int, input().split()))
s=set(a)
ans=0
for i in range(-1,102):
  if (i not in s) and abs(ans-X)>abs(i-X):
    ans=i
print(ans)

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

p = list(map(int,input().split()))
if p.count(X) == 0:
    print(X)
    exit()


l = list(range(0,102)) 
flist = []
for i in range(len(l)):
    if p.count(l[i]) == 0:
        flist.append(l[i])


flist.append(X)
anslist = sorted(flist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] 
dist2 = anslist[t+1] - anslist[t] 
if dist1 <= dist2:
    print(anslist[t-1])
else:
    print(anslist[t+1])

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

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

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

if __name__ == "__main__":
    main()

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

counter = 0

while True:
    if x - counter not in ps:
        ans = x - counter
        break
    elif x + counter not in ps:
        ans = x + counter
        break
    else:
        counter += 1

print(ans)

Solution (Python):
import sys

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

p.sort()

if x not in p:
    print(x)
    sys.exit()

for i in range(0, 100):
    if (x - i) not in p:
        print(x - i)
        sys.exit()
    if (x + i) not in p:
        print(x + i)
        sys.exit()

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


if n == 0:
    print(x)
else:
    i = 0
    while True:
        if x - i not in list_p:
            print(x-i)
            break
        elif x + i not in list_p:
            print(x+i)
            break
        else:
            i += 1

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

dist=1000
ans=1000
for i in range(101,-1,-1):
  if i in p:
    continue
  t_dist=abs(x-i)
  if t_dist<=dist:
    ans=i
    dist=t_dist

print(ans)

Solution (Python):
X, N = input().split()
p = input().split()
X = int(X)
N = int(N)
min = 101
ans = -100
for i in range(-101, 102):
    if str(i) in p:
        continue
    a = abs(i - X)
    if a < min:
        min = a
        ans = i
print(ans)

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

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

for i in range(100):
    if (x-i) not in num_list:
        print(x-i)
        exit()

    if (x+i) not in num_list:
        print(x+i)
        exit()

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

for i in range(101):
    if (x-i) not in num_list:
        print(x-i)
        exit()

    if (x+i) not in num_list:
        print(x+i)
        exit()

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

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

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

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

Solution (Python):




x, y = map(int, input().split() )
num_list = list( map(int, input().split() ) )

try:
        num_list.remove(x)

        for i in range(1,101):
                try:
                        num_list.remove(x - i)
                except ValueError:
                        print(x - i)
                        break

                try:
                        num_list.remove(x + i)
                except ValueError:
                        print(x + i)
                        break

except ValueError:
        print(x)

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

Q=[0]*102
for i in range(0,102):
    Q[i]=abs(X-i)


for i in  p:
    Q[i]=1000

print(Q.index(min(Q)))

Solution (Python):
import sys

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

i = 0
for i in range(100):
    A = X - i
    if A not in P_LIST:
        X_min = A
        for j in range(100):
            B = X + j
            if B not in P_LIST:
                X_max = B
                if X_max - X < X - X_min:
                    print(X_max)
                    sys.exit()
                else:
                    print(X_min)
                    sys.exit()

Solution (Python):
import sys

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

if N == 0:
  print(X)
else:
  argv = input().split()
  argv.sort()

  for num in range(100):
    out = 0
    for i in range(N):
      if int(argv[i]) == X - num:
        out = 1
        
    if out == 0:
      print(X - num)
      break;
      
    out = 0
    
    for i in range(N):
      if int(argv[i]) == X + num:
        out = 2
    
    if out == 0:
      print(X + num)
      break;

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

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)

Solution (Python):
import sys
from collections import Counter
X, N = [int(x) for x in input().split()]
P = []
if N:
    P = [int(x) for x in input().split()]

CP = Counter(P)
if CP[X] == 0:
    print(X)
    sys.exit()

for d in range(1, 1000):
    if CP[X - d] == 0:
        print(X - d)
        break
    elif CP[X + d] == 0:
        print(X + d)
        break

Solution (Python):
X, N = [int(x) for x in input().strip().split()]
p = set([int(x) for x in input().strip().split()])
ans = 0
diff = X
for i in range(102):
  if i in p:
    continue
  if abs(X - i) < diff:
    ans = i
    diff = abs(X - i)
print(ans)

Solution (Python):
import sys

X,N = map(int,input().split())
P = list(map(int,input().split()))
if X < 1 or 100 < X:
    sys.exit()
if N < 0 or 100 < N:
    sys.exit()
if N == 0:
    print(X)
    sys.exit()

P_number = len(P)
if P_number < 1 or 100 < P_number:
    sys.exit()

res1 = 100
res2 = 100
res0 = 0
i = 0
j = 0
while i <= N:
    if (X - i) not in P:
        res1 = (X - i)
        break
    i += 1
while j <= N:
    if (X + j) not in P:
        res2 = (X + j)
        break
    j += 1
if i > j:
    res0 = res2
elif j > i:
    res0 = res1
elif i == j:
    res0 = res1
print(res0)

Solution (Python):
X, N = list(map(int, input().split()))
if N == 0: print(X)
else:
    p = list(map(int, input().split()))
    if not X in p:
        print(X)
    else:
        q = [X-1, X+1]

        while True:

            if not q[0] in p:
                print(q[0])
                break
            elif not q[1] in p:
                print(q[1])
                break
            q = [q[0]-1, q[1]+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:
    n = [x for x in range(102)]

    for i in p:
      n.remove(i)
    ans = 0  
    a = 101
    b = -1
    for j in n:
      b += 1
    
      if abs(j-X) < a:
        a=abs(j-X)
        ans = n[b]
  
    print(ans)

Solution (Python):
import sys

X, Y = map(int, input().split())
N_list = list(map(int,input().split()))
N_answer = []

if len(N_list) == 0:
    print(X)
    sys.exit()
for i in range(100):
    if (X + i) not in N_list:
        N_answer.append(X + i)
    if (X - i) not in N_list:
        N_answer.append(X - i)
    
    if len(N_answer) > 0:
        break

print(min(N_answer))

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

P = list(map(int, input().split()))
t = 100
for i in range(0,102):
  if not i in P:
    if t > abs(i - x):
      t = abs(i - x)
      ans = i

print(ans)

Solution (Python):



import numpy
from bisect import bisect_left

def main():
  x, n = map(int, input().split())
  if n == 0:
    print(x)
    return
  
  lp = sorted(list(map(int, input().split())))
  cands = numpy.array(list(set(range(0, 102)) - set(lp))) - x
  i = bisect_left(cands, 0)
  a, b = cands[:i][::-1][0], cands[i:][0]
  if abs(a) > abs(b):
    print(x+b)
  else:
    print(x+a)

if __name__=='__main__':
  main()

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

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

Solution (Python):
x, n = map(int, input().split())
a = list(map(int, input().split()))
for i in range(105):
    if (x-i) not in a:
        print(x-i)
        exit()
    if (x+i) not in a:
        print(x+i)
        exit()

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

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

result = 100

l = list(range(0,102))



if len(p) == 0:
    kotae = x
else:
    for i in range(len(p)):

        l[p[i]] = ""



    for i in reversed(range(len(l))):
     
        if l[i] != "":

            if result >= abs(l[i] - x):
                result = abs(l[i] - x)
               
                kotae = l[i]          
            
print(kotae)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
num = [i for i in range(1, 101) if i not in p]
l = 0
r = 101
for i in num:
    if i <= x:
        l = max(l, i)
    else:
        r = min(r, i)

if l+r == 2*x:
    ans = l
elif x-l < r-x:
    ans = l
else:
    ans = r

print(ans)

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

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

for l in L:
    NL.remove(l)

NL.append(X)
NL.sort()

LR = NL.index(X)+1
LL = NL.index(X)-1


if (NL[LR]-X) < (X-NL[LL]):
    print(NL[LR])
else:
    print(NL[LL])

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

z = list(range(-2,105))
x,n = inpl()
a = inpl()
for i in a:
    if i in z:
        z.remove(i)
res = -1
sa = INF
for i in z:
    if abs(x-i) < sa:
        res = i
        sa = abs(x-i)
print(res)

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

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

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

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

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

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

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

try:
    p = list(map(int, input().split()))
except EOFError:
    print(X)
    exit()

i = 0
while True:
    tmp1 = X - i
    tmp2 = X + i

    if tmp1 not in p:
        print(tmp1)
        exit()
    if tmp2 not in p:
        print(tmp2)
        exit()

    i += 1

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)
        exit()
    elif x + i not in p:
        print(x+i)
        exit()
    i += 1

Solution (Python):

def aa():
    x,n=[int(i) for i in input().strip().split(' ')]
    if n==0:
        print(x)
        return 
    arr=[int(i) for i in input().strip().split(' ')]
    
    
    
    
    
    
    
    
    
    diff=[]
    for i in arr:

        diff.append(x-i)
    i=-1
    j=0
    while i in diff:
        i=i-1
    while j in diff:
        j=j+1
    if abs(i)<abs(j):
        print(x-i)
    else:
        print(x-j)
    
aa()

Solution (Python):
x , n = map(int , input().split())
b = []
if n!=0:
    b = list(map(int,input().split()))
t = 0
ans = 0
while 1:
    if x-t not in b:
        ans = x - t
        break
    if x+t not in b:
        ans = x + t
        break
    t += 1
print(ans)

Solution (Python):
def main():
    x,n=map(int,input().split())
    pp=set(map(int,input().split()))
    if x not in pp:
        print(x)
        return
    i=1
    while True:
        if x-i not in pp:
            print(x-i)
            return
        elif x+i not in pp:
            print(x+i)
            return
        i+=1

main()

Solution (Python):

def main():
    target, N = map(int, input().split())
    p = list(map(int, input().split()))

    for i in range(101):
        if target - i not in p:
            print(abs(target - i))
            return
        if target + i not in p:
            print(abs(target + i))
            return


if __name__ == "__main__":
    main()

Solution (Python):
X, N = map(int,input().split())
answer = 0
if N != 0:
  mapped_list = map(int,input().split())
  list = list(mapped_list)
  for i in range (N):
    if (X-i in list) == False:
      answer = X-i
      break
    elif (X+i in list) == False:
      answer = X+i
      break
else:
  answer =X

print(answer)

Solution (Python):

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



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

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

else:
    for i in range(0,101):
        if l.count(int(X))<1:
            print(int(X))
            break 


        elif l.count(int(X-i))<1:
            print(int(X-i))
            break 

    

        if X+i<=101:
            if l.count(int(X+i))<1:
                print(int(X+i))
                break

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline

    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    candidate = [i for i in range(-100, 200)]

    ans = list()

    for c in candidate:
        if c not in p:
            diff = abs(c - x)

            ans.append((diff, c))

    print(sorted(ans)[0][1])


if __name__ == '__main__':
    main()

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

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

w, cnt = 0, 0
while cnt < 201:
  if x + w not in p:
    print(x + w)
    break

  w += ((-1) ** cnt) * cnt
  cnt += 1

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):
I = lambda : list(map(int,input().split()))
x,n = I()
l=I()
for i in range(101):
  if (x-i) not in l:
    print(x-i);break
  elif (x+i) not in l:
    print(x+i);break