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

P = input().split()
P = [int(c) for c in P]

i = X
j = X

if len(P) == 0:
    print(X)    
elif X  not in P:
    print(X)
else:
    while i < 101:
        i += 1
        if i not in P:
            break
    while j > 0:
        j -= 1
        if j not in P:
            break
    
    if i - X >= X - j:
        print(j)
    else:
        print(i)

Solution (Python):
import random

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

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)    
else:
    L = list(range(max(0,X-N),min(102,X+N)))

    if X+N <= 101:
        L.append(X+N)

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(L)]

    if X in L:
        print(X)
    elif len(L) == 1:
        print(L[0])
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

Solution (Python):
number = input().split(" ")
X = int(number[0])
N = int(number[1])

while True:
    try:
        numbers = input().split(" ")
        i = 0
        n = X
        while n > -1000 :
            if str(n) in numbers:
                i += 1
                n = n - (i * (-1)**(i-1))
            else:
                print(n)
                break
        break
    except:
        print(X)
        break

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

cnt = 0
while True:
    y = x - cnt
    if y not in s:
        print(y)
        break
    y = x + cnt
    if y not in s:
        print(y)
        break
    cnt += 1

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

ans1=100
ans=0
if N==0:
    print(X)
else:
    for i in range(102):
        if i in p:
            continue
        elif abs(X-i)<ans1:
            ans =i
            ans1 = abs(X-i)
    print(ans)

Solution (Python):
XN = list(map(int, input().split(' ')))
if XN[1] == 0:
    print(XN[0])
else:
    p = list(map(int, input().split(' ')))
    count = [0] * 110
    for i in range(XN[1]):
        count[p[i] + 5] += 1
    for i in range(60):
        if count[XN[0] + 5 - i] == 0:
            print(XN[0] - i)
            break
        elif count[XN[0] + 5 + i] == 0:
            print(XN[0] + i)
            break

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

import itertools

X,N = map(int,readline().split())
p = list(map(int,readline().split()))
ans = -INF
now = INF
for i in range(-10,105):
    if i not in p:
        if now > abs(X-i):
            ans = i
            now = abs(X-i)
print(ans)

Solution (Python):
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    pass
    
    
    
    X, N = input().split()
    X, N = int(X), int(N)
    if N == 0:
        print(X)
        exit(0)
    P = [int(i) for i in input().split()]
    P = list(set(P))

    i = 0
    while True:
        v = X-i
        if not (v in P):
            print(v)
            exit(0)
        v = X+i
        if not (v in P):
            print(v)
            exit(0)
        i += 1

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
tmp = 101
ans = 101
for i in range(-200, 201):
    if i not in p:
        if tmp == abs(X-i):
            if ans > i:
                ans = i
        elif tmp >= abs(X-i):
            ans = i
            tmp = abs(X-i)
print(ans)

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
tmp = 101
ans = 101
for i in range(-100, 201):
    if i not in p:
        if tmp == abs(X-i):
            if ans > i:
                ans = i
        elif tmp >= abs(X-i):
            ans = i
            tmp = abs(X-i)
print(ans)

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

Solution (Python):
'''
例
6 5
4 7 10 6 5

１．X = 6 との差を求める
(X-P_iの配列を作る)
2 -1 -4 0 1

2. X-P_iの配列に0, ±1, ±2, ... が含まれていないか調べる


3. 数列Pに含まれていない数で
6との差が-2になる8
'''

import numpy as np

def pm_list(i):
    if(i%2 == 0):
        return i//2
    else:
        return -i//2

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

def_list = np.array(P) - X

i = 0
while True:
    iter_num = pm_list(i) 
    if not (iter_num in def_list):
        print(X + iter_num)
        break
    i += 1

Solution (Python):
import bisect
def main():
  X, N = map(int, input().split())
  if N == 0:
    print(X)
    return
  P = set(map(int, input().split()))

  NP = sorted(list(set(range(-1,102)) - P))
  right = bisect.bisect(NP, X)
  left = right - 1
  if abs(X - NP[left]) > abs(X - NP[right]):
    print(NP[right])
  else:
    print(NP[left])

main()

Solution (Python):
import bisect
def main():
  X, N = map(int, input().split())
  if N == 0:
    print(X)
    return
  P = set(map(int, input().split()))

  NP = sorted(list(set(range(102)) - P))
  right = bisect.bisect(NP, X)
  left = right - 1
  if left == -1 or abs(X - NP[left]) > abs(X - NP[right]):
    print(NP[right])
  else:
    print(NP[left])

main()

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
q=p
s=0
for i in range(n):
    p[i]-=x
for i in range(100):
    t=0
    for j in range(n):
        if p[j]==i:
            t+=1
        if p[j]==-i:
            t+=2
    s=i
    if t!=3:
        break
if t==0 or t==1:
    print(x-s)
else:
    print(x+s)

Solution (Python):
import collections
import heapq
import math
import random
import sys
input = sys.stdin.readline

sys.setrecursionlimit(500005)
read_int = lambda: int(ns())
read_list = lambda: list(map(int, input().split()))
read_string = lambda: input().rstrip()

x, n = read_list()
p = set(read_list())
res = 1000000
for i in range(-100, 300):
    if i in p:
        continue
    if abs(i - x) < abs(res - x) or (abs(i - x) == abs(res - x) and i < res):
        res = i
print(res)

Solution (Python):



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

for i in range(101):  
    length = x - i
    result = x + i
    if length not in P:
        print(length)
        break
    elif result not in P:
        print(result)
        break

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

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
for D in range(X + 1):
    for S in [-1, +1]:
        A = X + S * D
        if P.count(A) == 0:
             print(A)
             exit(0)

Solution (Python):

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

             print(x)

             exit(0)

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

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

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

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

x, n = map(int, input().split())
s = list(map(int, input().split()))
for i in range(x + 1):
    for op in [-1, 1]:
        if (v := op * i + x) not in s: print(v); exit()
print('GayLand')

Solution (Python):
X, N = map(int, input().split())
judge = 102*[1]
if N==0:
	print(X)
	exit()

P = list(map(int, input().split()))
for i in range(N):
	judge[P[i]] = 0

upcnt = 0
while judge[X+upcnt]==0:
	upcnt+=1

downcnt = 0
while judge[X-downcnt]==0:
	downcnt+=1

if upcnt < downcnt:
	print(X+upcnt)
else:
	print(X-downcnt)

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

Solution (Python):
x,n=map(int,input().split())
p=list(map(int, input().split()))
youso=[]
for i in range(-300,1000):
    if not i in p:
        youso+=[i]
hikaku=[]
for i in youso:
    hikaku+=[(i,abs(x-i))]
hikaku1=sorted(hikaku,key=lambda x:x[1])
res=hikaku1[0][0]
print(res)

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

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

p = list(map(int,input().split()))
p = [-1] + p + [102]
import bisect
p.sort()
i = bisect.bisect_left(p,x)
if p[i] != x:
    print(x)
    exit()

for h in range(102):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()

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

for i in range(101):
  xl = x - i
  xr = x + i
  if xl not in P:
    print(xl)
    break
  elif xr not in P:
    print(xr)
    break

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

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

forbid = [True]*102

for i in range(len(p)):
    if forbid[p[i]]:
        forbid[p[i]] = False
        
pp = []

for i in range(len(forbid)):
    if forbid[i]:
        pp.append(i-X)

num = pp[len(pp)-1]        
for i in range(len(pp)-1,-1,-1):
    if abs(num) >= abs(pp[i]):
        num = pp[i]
        
print(num+X)

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

forbid = [True]*102

for i in range(len(p)):
    if forbid[p[i]]:
        forbid[p[i]] = False
        
pp = []

for i in range(len(forbid)):
    if forbid[i]:
        pp.append(i-X)





        
print(pp[np.argmin(np.abs(pp))]+X)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x,n=map(int, input().split())
    l=list(map(int,input().split()))
    for i in range(100):
        if x-i not in l:
            print(x-i)
            break
        elif x+i not in l:
            print(x+i)
            break
resolve()

Solution (Python):

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

def resolve():
    x,n=map(int, input().split())
    l=list(map(int,input().split()))
    samin=1000
    ans=1000
    for i in range(102):
        if i not in l and abs(i-x)<samin:
            samin=abs(i-x)
            ans=i
    print(ans)
resolve()

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

min = 1000
pre_i = 0
for i in range(102):
    if i in p:
        continue
    if min > abs(x - i):
        min = abs(x - i)
    else:
        break
    pre_i = i

print(pre_i)

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

for i in range(100):
	for j in [-1, 1]:
		t = X + i * j
		if t not in P:
			print(t)
			exit(0)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
mem = []
mind = 100
for i in range(-100, 200):
    if i not in p:
        t = abs(x-i)
        if t < mind:
            mem.append([i, t])
            mind = t
mem = sorted(mem, key=lambda x: (x[1], x[0]))
print(mem[0][0])

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

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

  
  

for dist in range(b+1):
  for signed in [-1,1]:
    x = a + signed*dist
    if c.count(x) == 0:
      print(x)
      exit(0)

Solution (Python):
a,b = map(int,input().split())
if(b != 0):
  c = list(map(int,input().split()))
else:
  print(a)
  exit()
ans = 0
for i in range(101):
  if(a+i not in c):
    if(a+i > 101):
      break
    else:
      ans = a+i
      break
for i in range(101):
  if(a-i not in c):
    if(a-i < 0):
      break
    else:
      if(i < abs(a-ans)):
        ans = a-i
      elif(i == abs(a-ans)):
        ans = min(a-i,ans)
      break
print(ans)

Solution (Python):
def resolve():
    x, n = [int(i) for i in input().split()]
    if n != 0:
        l = [int(i) for i in input().split()]
    c = 0
    while 1:
        if n == 0:
            print(x)
            break
        if not(x - c in l):
            print(x - c)
            break
        elif not(x + c in l):
            print(x + c)
            break
        c += 1
resolve()

Solution (Python):
X,N = list(map(int, input().split()))
p = list(map(int,input().split())) 
for i in range(N + 1):
  a = X + i
  b = X - i
  if p.count(b) == 0:
    print(b)
    exit(0)
  elif p.count(a) == 0:
    print(a)
    exit(0)

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

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

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

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

a = x
while True:
    if not a in plist:
        big = a
        break
    a += 1

b = x-1
while True:
    if not b in plist:
        small = b
        break
    b -= 1

if abs(big-x) < abs(small-x):
    ans = big
else:
    ans = small

print(ans)

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

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

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

          if not minus in ps:
              print(minus)
              break
          elif not plus in ps:
              print(plus)
              break

          i += 1

Solution (Python):
x,n = list(map(int,input().split()))
a = list(map(int,input().split()))
xp = x
xm = x
for i in range(n//2+2):
  if xm not in a:
    print(xm)
    exit(0)
  if xp not in a:
    print(xp)
    exit(0)    
  xp += 1
  xm -= 1

Solution (Python):
X,N = map(int,input().split())
A = list(map(int,input().split()))
import sys
for d in range(X+1):
  for i in [-1,1]:
    B = X + d*i
    if A.count(B) == 0:
      print(B)
      sys.exit()

Solution (Python):
  
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))



x,n = readints()
p = readints()

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

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

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

Ans = 400

for i in range(102):
    if max(0,X-i) in p:
        Ans = Ans
    else:
        Ans = max(0,X-i)
        break
    if min(101,X+i) in p:
        Ans=Ans
    else:
        Ans = min(101,X+i)
        break
print(Ans)

Solution (Python):
def fun():
    x, n = list(map(int, input().split()))
    if n == 0: return x
    num_list = list(map(int, input().split()))
    hashmap = {num: True for num in num_list}
    if x not in hashmap: return x
    a = []
    i = 1
    answer = float('inf')
    for _ in range(n):
        for dif in (-1*i, +1*i):
            if x+dif not in hashmap:
                a.append(x + dif)
            if len(a) == 2:
                break
        if len(a) == 2:
            break
        i += 1
    
    answer = min([(abs(num-x), num) for num in a])
    return answer[1]
    
print(fun())

Solution (Python):

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

i=j=x

while i in l:
    i += 1
while j in l:
    j -= 1

if abs(x-i) < abs(x-j):
    print(i)
else:
    print(j)

Solution (Python):
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
tmp = 100
ans = 0
for i in range(0, 102):
    dif = abs(i-x)
    if i not in p and dif < tmp:
        tmp = dif
        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):
from collections import defaultdict

x,n = map(int,input().split())
if n==0:
    print(x)
else:
    dd = defaultdict(int)
    arr = list(map(int,input().split()))
    for i in range(len(arr)):
        dd[x-arr[i]]+=1

    for i in range(101):
        if dd[i]==0:
            print(x-i)
            break
        elif dd[-i]==0:
            print(x+i)
            break

Solution (Python):
x, n = map(int, input().split())
p_l = list(map(int, input().split()))
p_l.sort()
if p_l == [] :
    print(x)
else :
    ans = [x, x]
    while True :
        if ans[0] not in p_l :
            print(ans[0])
            break
        elif ans[1] not in p_l :
            print(ans[1])
            break
        else :
            ans[0] -= 1
            ans[1] += 1

Solution (Python):
from bisect import bisect_left

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


if N == 0:
    print(X)

else:
    plist.sort()
    not_plist = [x for x in range(plist[0]-1, plist[-1]+2, 1)  if x not in plist]
    idx = bisect_left(not_plist, X)

    if idx == 0:
        print(X)

    elif idx == len(not_plist):
        print(X)

    else:
        left = X - not_plist[idx-1]
        right = not_plist[idx] - X
        if left <= right:
            print(not_plist[idx-1])
        else:
            print(not_plist[idx])

Solution (Python):
def solve(x, n, nums):
	if not nums or x not in nums:
		return x
	a = x - 1
	b = x + 1
	while True:
		if a not in nums:
			return a
		if b not in nums:
			return b
		a -= 1
		b += 1

x, n = map(int, input().split())
A = None
if n > 0:
	A = set(list(map(int, input().split())))
print(solve(x, n, A))

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

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

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

    i += 1

Solution (Python):

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

Solution (Python):
import numpy as np
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    l = list(map(int, input().split()))
    app = [x for x in range(X - int(N / 2) - 1, X + int(N / 2) + 1) if x not in l]
    print(app[np.argmin([abs(x - X) for x in app])])

Solution (Python):
x, n = map(int, input().split())
try:
	p_li = list(map(int, input().split()))
except:
	print(x)
	exit()

for i in range(100000):
	
	if not((x - i) in p_li):
		print(x - i)
		break
	
	if not((x + i) in p_li):
		print(x + i)
		break

Solution (Python):
if __name__=="__main__":
    X,N = list(map(int,input().split()))
    p = list(map(int,input().split()))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit(0)

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

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

mi = 1000
ans = x
for i in range(105):
    for j in range(n):
        if p[j] == i:
            break
        if j == n - 1:
            if abs(x - i) < mi:
                mi = abs(x - i)
                ans = i
print(ans)

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

for i in range(101):
  xl = x - i
  xr = x + i
  if xl not in P:
    print(xl)
    break
  if xr not in P:
    print(xr)
    break

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

array=list(map(int,input().split()))
P=[]
for i in array:
    P.append(i)

if not X in P:
    best=X
else:
    i=1
    while True:
        if not X-i in P:
            best=X-i
            break
        if not X+i in P:
            best=X+i
            break
        i+=1

print(best)

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

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

for i in range(102):
  xl = x - i
  xr = x + i
  if xl not in P:
    print(xl)
    break
  elif xr not in P:
    print(xr)
    break

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

while True:
    if liste.count(x)==0:
        print(x)
        break
    if liste.count(roger)==0:
        print(roger)
        break

    x -=1
    roger+=1

Solution (Python):
X, N = map(int,input().split())
P = list(map(int,input().split()))
Q =[]
for i in range(-1,102):
    Q.append(i)
A = list(set(Q) - set(P))
min = 200
ans = 1000
for i in range(len(A)):
    if abs(X - A[i]) < min:
        min = X - A[i]
        ans = A[i]
print(ans)

Solution (Python):
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    INF = 1e9+7
    
    x, n = map(int,raw_input().split())
    
    arr = map(int,raw_input().split())
    
    s = set(arr)
    
    ret = INF
    
    for num in range(102):
        if num not in s:
            diff = abs(num - x)
            ret_diff = abs(ret - x)
            if diff < ret_diff:
                ret = num
            elif diff == ret_diff and num < ret:
                ret = num
    
    print(ret)
    

main()

Solution (Python):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


x,n=MAP()
if n==0:
    print(x)
    exit()
a=LI()
l=-1;r=-1
for i in range(101):
    if x-i not in a:
        l=x-i
        break
for i in range(101):
    if x+i not in a:
        r=x+i
        break
if abs(r-x)>=abs(l-x):
    print(l)
else:
    print(r)

Solution (Python):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


x,n=MAP()
if n==0:
    print(x)
    exit()
a=LI()
l=-1;r=-1
for i in range(1000):
    if x-i not in a:
        l=x-i
        break
for i in range(1,101):
    if x+i not in a:
        r=x+i
        break
if abs(r-x)>=abs(l-x):
    print(l)
else:
    print(r)

Solution (Python):
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

x,n = (int(a) for a in input().split())
seq = set((int(i) for i in input().split()))
i = 0
while True:
    if x - i not in seq:
        ans = x-i
        break
    if x + i not in seq:
        ans = x + i
        break
    i += 1
print(ans)

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

Solution (Python):
import sys
x,n = map(int,input().split())
l = list(map(int,input().split()))
not_l,ans = [],[]
if not x in l:
	print(x)
	sys.exit()
l = sorted(l)
for i in range(0,max(l)+3):
	if not i in l:
		not_l.append(i)
for j in range(len(not_l)):
	ans.append([not_l[j],abs(not_l[j]-x)])
ans.sort(key=lambda x:x[1])
print(ans[0][0])

Solution (Python):
def main():
  X,N = list(map(int, input().split()))
  P = list(map(int, input().split()))
  
  Q = set([i for i in range(0,101+1)])
  for p in P:
    Q.remove(p)
  Q = sorted(Q)
  
  D = [abs(q-X) for q in Q]
  
  minD = min(D)
  for d,q in zip(D,Q):
    if d==minD:
      break
  print(q)
    
if __name__=='__main__':
  main()

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

Solution (Python):

from collections import Counter
a,b=list(map(int,input().split()))
m=list(map(int,input().split()))

c=[]
for i in range(b):
    c.append(abs(m[i]-a))
c=Counter(c)

if b>0:
    i=0
    while i<=b:
        if i not in c:
            print(a-i)
            break
        
        elif c[i]<2 and i!=0:
            if a-i in m:
                print(i+a)
            else:
                print(-i+a)
            break
        i+=1
else:
    print(a)

Solution (Python):
X, N = map(int, input().split()) 
p = list(set(range(-100,150)).difference(map(int, input().split())))[::-1]

abs_num = abs(X - 150)
result = 100

for x in p:
  tmp_abs = abs(X - x)
  if tmp_abs <= abs_num:
    abs_num = tmp_abs
    result = x
    
print(result)

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

Solution (Python):
x,n = map(int, input().split())
lst = list(map(int, input().split()))[:n]
incr = 0
ans = 0
while True:
    found = True
    now = x-incr
    for ele in lst:
        if now == ele:
            found = False
    if found == True:
        ans = now
        break
    found = True
    now = x + incr
    for ele in lst:
        if now == ele:
            found = False
    if found == True:
        ans = now
        break
    incr = incr + 1
print(ans)

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

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

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

print(ans)

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

ans = x
diff = 10**3

for i in range(101,-2,-1):
  if n > 0:
    if not i in arr:
      if abs(x-i) <= diff:
        diff = abs(x-i)
        ans = i
print(ans)

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

Solution (Python):
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))


def resolve():
    x,n = mi()
    p = mi()

    for d in range(x+1):
        for o in [-1,1]:
            val = x + o*d
            if val not in p:
                print(val)
                return

if __name__ == "__main__":
    resolve()

Solution (Python):
from sys import exit
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
np = {i for i in range(0, 102)} - set(map(int, input().split()))
t = len(np)
d = 100
for _ in range(t):
    i = np.pop()
    if d > abs(x - i):
        d = abs(x - i)
        ans = i
print(ans)

Solution (Python):
from sys import exit
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
s = {i for i in range(0, 102)}
np = s - set(map(int, input().split()))
t = len(np)
d = 100
ans = 0
for _ in range(t):
    i = np.pop()
    if d > abs(x - i):
        d = abs(x - i)
        ans = i
print(ans)

Solution (Python):
from sys import stdin
data = stdin.readlines()

x = int(data[0].split()[0])
n = int(data[0].split()[1])
if n >= 1:
    p = [int(s) for s in data[1].split()]
else:
    p = []

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