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()
P = list(map(int, input().split(" ")))
P.sort()

for i in range(N):
  if(P[i] > X):
    L = P[:i][::-1]
    U = P[i:]
    break
  elif(i == N-1):
    L = P[::-1]
    U = []

if (len(L) == 0 or L[0] != X):
  print(X)
  exit()

lans = -1
for i in range(1, len(L)):
  if (L[i-1] - L[i] > 1):
    lans = L[i-1]-1
    break
if(lans == -1):
  lans = L[len(L)-1]-1

if (len(U) == 0 or U[0] != X+1):
  uans = X+1
else:
  uans = -1
  for i in range(1, len(U)):
   if (U[i] - U[i-1] > 1):
      uans = U[i-1]+1
      break
  if(uans == -1):
    uans = U[len(U)-1]+1

if(abs(lans-X) <= abs(uans-X)):
  print(lans)
else:
  print(uans)

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

if n==0:
  print(x)
  sys.exit()
 
for i in range(0, 101):
  if not((x-i) in ps):
    print(x-i)
    sys.exit()
  if not((x+i) in ps):
    print(x+i)
    sys.exit()

Solution (Python):
x, n = [int(_) for _ in input().rstrip("\n").split(" ") if _]
if n > 0:
  p = set([int(_) for _ in input().rstrip("\n").split(" ")])
else:
  p = set([])
for diff in range(51):
    if not (x - diff) in p:
        print((x - diff))
        break
    if not (x + diff) in p:
        print((x + diff))
        break

Solution (Python):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = set(map(int, input().split()))
    NP = [i for i in range(0, 102) if i not in P]
    mx = 102
    for p in NP:
        mx = min(mx, p, key=lambda p: abs(x-p))
    print(mx)

Solution (Python):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = set(map(int, input().split()))
    NP = [i for i in range(0, 102) if i not in P]
    mx = 102
    for p in NP:
        if abs(x-p) < abs(x-mx):
            mx = p
    print(mx)

Solution (Python):
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
List=list(map(int,input().split()))
ans=list(range(0,102))
min_num=1000
for i in List:
    ans.remove(i)
for i in ans:
    if(abs(i-x)<abs(min_num-x)) or (abs(i-x)==abs(min_num-x) and i<min_num):
        min_num=i
print(min_num)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X, N = LI()
p = LI()

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

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

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

Solution (Python):
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
List=list(map(int,input().split()))
ans=list(range(0,102))
min_num=1000
for i in List:
    ans.remove(i)
for i in ans:
    if (abs(i-x)<abs(min_num-x)) or (abs(i-x)==abs(min_num-x) and i<min_num):
        min_num=i
print(min_num)

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

max = X
min = X

while True:
    if min not in p:
        print(min)
        exit()
    if max not in p:
        print(max)
        exit()
    max+=1
    min-=1

Solution (Python):
X, N = map(int, input().split())
if N==0: print(X);exit()
p = list(map(int, input().split()))
count = 0
while True:
  if X - count not in p:
    print(X-count)
    exit()
  if X + count not in p:
    print(X+count)
    exit()
  count += 1

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

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

Solution (Python):
import sys
x,n=map(int,input().split())
if n == 0:
  print(x)
  sys.exit()
  
a={int(i) for i in input().split()}
i=0
while True:
  if not (x-i) in a:
    print(x-i)
    sys.exit()
  
  if not (x+i) in a:
    print(x+i)
    sys.exit()
  i+= 1

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

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

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  q = [True] * 102
  for i in range(n):
    q[p[i]] = False
  d_min = 10**3
  for j in range(102):
    if q[j]:
      d = abs(x - j)
      if d_min > d:
        d_min = d
        ans = j
  print(ans)

Solution (Python):
X,N = map(int,input().split())
P = {}
if N > 0:
  for p in input().split():
    i = int(p)
    P[i] = 0
x = X
n = -1
while True:
  if not x in P:
    break
  x = X + n
  n *= -1
  if n < 0:
    n -= 1
print(x)

Solution (Python):
x, n = map(int, input().split())
if n == 0: print(x); exit()
C = [0]*(101+1) 
for p in map(int, input().split()): C[p] = 1
for d in range(100):
    c = x - d
    if not C[c]: print(c); exit()
    c = x + d
    if not C[c]: print(c); exit()

Solution (Python):
x, n = map(int, input().split())
if n == 0: print(x); exit()
C = [0]*(101+1) 
for p in map(int, input().split()):
    C[p] = 1
ans = x
d = 1000000000
for c in range(101+1):
    if not C[c] and d > abs(x - c):
        d = abs(x - c)
        ans = c
print(ans)

Solution (Python):
X, N = map(int, input().split())
if X <= 50:
  l = X
  d = 0
else:
  l = 101 - X
  d = 101

if N == 0:
  print(X)
  exit()
elif N == 100:
  print(d)
  exit()
else:
  p = set(map(int, input().split()))

for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li == l:
      if i+1 < d:
        d = i+1
    elif li > l:
      break
print(d)

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

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

Solution (Python):

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

result = X

try:
    p = set(map(int, input().split()))
    if X not in p:
        result = X
    else:
        for i in range(1, 101):
            if X - i not in p:
                result = X - i
                break
            elif X + i not in p:
                result = X + i
                break
    print(result)
except:
    print(result)

Solution (Python):
X, N = map(int, input().split())
if N > 0:
    P = list(map(int, input().split()))
    A = [0]*102
    cnt = 0
    res = float('Inf')
    for n in range(N):
        A[P[n]] += 1
    for a in A:
        if a == 0:
            total = abs(X - cnt)
            if res > total:
                res = total
                man = cnt
        cnt += 1
    print(man)
else:
    print(X)

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


P_n = [i for i in range(102) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Solution (Python):
x,n,*p=map(int,open(i:=0).read().split())
while x in p:x+=(-1)**i*i;i+=1
print(x)

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


P_n = [i for i in range(102) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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


P_n = [i for i in range(105) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Solution (Python):
def actual(X, N, P):
    
    nums = set(range(0, 101 + 1)) - set(P)

    
    return min(nums, key=lambda n: abs(n - X))

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

print(actual(X, N, P))

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


P_n = [i for i in range(110) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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

P_n = [i for i in range(110) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]

import sys

min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        sys.exit()

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

d_min = 1000
ans = 1000
for num in range(-1, 102):
    if num in P:
        continue
    
    d = abs(x-num)
    if d < d_min:
        d_min = d
        ans = num

print(ans)

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

if N == 0:
  print(X)
else:
  P = set(map(int, input().split()))
  for i in range(N + 1):
    if X - i not in P:
      print(X - i)
      break
    elif X + i not in P:
      print(X + i)
      break

Solution (Python):
X, N = map(int, input().split())
 
p = list(map(int, input().split()))
 
p_none = [i for i in range(110) if i not in p]
p_none_sa = [abs(p_none[i]-X) for i in range(len(p_none))]
 
import sys
 
min_p_none = min(p_none_sa)
for i in range(len(p_none_sa)):
    if p_none_sa[i] == min_p_none:
        print(p_none[i])
        sys.exit()

Solution (Python):
X, N = map(int, input().split())
*P, = map(int, input().split())
l = set(range(-200, 200)) - set(P)
m = 10 ** 7
ans = 0
for i in l:
    if abs(i - X) < m:
        ans = i
        m = abs(i - X)
print(ans)

Solution (Python):
a,b=map(int,input().split())
c=list(map(int,input().split()))
ans=0
for i in range(100):
    if a-i not in c:
        ans=a-i
        break
    elif a+i not in c:
        ans=a+i
        break
print(ans)

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

table = [0] * 102
for a in data:
    table[a] = 1

left = None
idx = x
while idx >= 0:
    if table[idx] == 0:
       left = idx
       break
    idx -= 1
idx = x
right = None
while idx < 102:
    if table[idx] == 0:
        right = idx
        break
    idx += 1

lscore = abs(x-left)
rscore = abs(x-right)

if lscore <= rscore:
    print(left)
else:
    print(right)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)

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

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


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

l=[0] * 102

for i in p:
    l[i] =1

diff=1000
ans=0
for i in range(0,102):
    if l[i] == 0 and diff > abs(x-i):
        diff= abs(x-i)
        ans=i

print(ans)

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

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

p_none = [i for i in range(110) if i not in p]
p_none_sa = [abs(p_none[i]-X) for i in range(len(p_none))]

import sys

min_p_none = min(p_none_sa)
for i in range(len(p_none_sa)):
    if p_none_sa[i] == min_p_none:
        print(p_none[i])
        sys.exit()

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

p.sort()
if len(p) == 0 or x < p[0] or p[-1] < x or x not in p:
    ans = x
else:
    d = x
    ans = 0
    for i in range(p[0] - 1, p[-1] + 2):
        if i not in p and abs(x - i) < d:
            ans = i
            d = 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()))
ans=0
check=100
for i in range(101+1):
  if i in p:
    continue
  if abs(X-i)<check:
    check=abs(X-i)
    ans=i
print(ans)

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

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

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(i)

nip_temp = []
for i in not_in_p:
    nip_temp.append(abs(x-i))

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

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


for i in range(200):
    if X - i not in ps:
        print(X-i)
        exit()
    elif X + i not in ps:
        print(X+i)
        exit()

Solution (Python):


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

if n == 0:
    print(x)
    
else:
    _x = x 
    x_ = x
    while True:
        if _x not in p:
            print(_x)
            break
        if x_ not in p:
            print(x_)
            break
        _x -= 1
        x_ += 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
    if x + i not in p:
        print(x + i)
        break

Solution (Python):
x , n = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
q = 10000
r = 10000
for i in range(0, 102):
    if i not in p:
        if q > abs(i-x):
            q = abs(i-x)
            r = i
print(r)

Solution (Python):
from sys import stdin
import sys
import math
import random
from decimal import Decimal
 
 
X, N = [int(x) for x in stdin.readline().rstrip().split()]
 
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))
 
ans = 10**9
ans1 = [X, 10**9]
for i in range(-100, 105):
    if i not in p:
        if ans > abs(X-i):
            ans = abs(X-i)
            
            if ans1[1] == abs(X-i):
                pass
            else:
                ans1[1] = abs(X-i)
                ans1[0] = i
            
            
            
                
print(ans1[0])

Solution (Python):
X, n = map(int, input().split())
print(min(set(range(0, 102))-set(map(int, input().split())), key=lambda x: abs(x-X)))

Solution (Python):
X, n = map(int, input().split())
Ps = set(map(int, input().split()))
cood = set(range(0, 102))
cood -= Ps
print(min(cood, key=lambda x: abs(x-X)))

Solution (Python):
X , N = map(int, input().split())
p = list(map(int,input().split()))
ans = []
if N == 0:
    print(X)
elif X not in  p:
    print(X)
else:
    p = sorted(p)
    p2 = [abs(i-X) for i in p]

    for i in range(p[p2.index(min(p2))],102):
        if i not in p:
            ans.append(i)
            break
    for i in range(p[p2.index(min(p2))], -100, -1):
        if i not in p:
            ans.append(i)
            break
    
    ans = sorted(ans)
    ans2 = [abs(i-X) for i in ans]
    print(ans[ans2.index(min(ans2))])

Solution (Python):

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    X, N = list(map(int, input().split()))
    p = list(map(int, input().split()))

    return X, N, p


def main(X: int, N: int, p: list) -> None:
    """
    求解処理を行う.

    Args:\n
        X (int): 整数
        N (int): 長さ
        p (list): 整数列
    """
    
    ans = 0
    diff = 0
    while True:
        
        x_minus = X - diff
        if x_minus not in p:
            ans = x_minus
            break
        
        x_plus = X + diff
        if x_plus not in p:
            ans = x_plus
            break

        diff += 1

    
    print(ans)


if __name__ == "__main__":
    X, N, p = get_input()
    main(X, N, p)

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

line = [0]*(102)
for p in Ps:
    line[p] = 1

for i in range(101):
    L, R = x-i, x+i
    if line[L] == 0:
        print(L)
        break
    if line[R] == 0:
        print(R)
        break

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

min_ = 100
for i in range(0, 102):
    cur = i 
    if cur in P:
        continue
    diff = abs(X - cur)
    if diff < min_:
        min_ = diff

front = X - min_
back = X + min_
if front not in P:
    print(front)
else:
    print(back)

Solution (Python):
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce


x, y = map(int, input().split())
if y == 0:
    print(x)
    exit()
p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n = p_n.reshape(-1)
pp = np.arange(0, 102)
for i in p_n:
    pp[i] += 10000
sa = min(abs(pp-x))
if sa <= 101:
    if pp[x-sa] >= 10000:
        print(x+sa)
    else:
        print(x-sa)
else:
    print("0")

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

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

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

for diff in range(200):
  if x-diff not in p:
    print(x-diff)
    exit()

  if x+diff not in p:
    print(x+diff)
    exit()

Solution (Python):
X, N = map(int, input().split())
try:
  p=set(map(int, input().split()))
except Exception:
  p=set()
i = 0
while 1: 
  ans = X - i
  if ans not in p:
    print(ans)
    break
  ans = X + i
  if ans not in p:
    print(ans)
    break
  i = i + 1

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

for i in range(110):
    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())
p_s = list(map(int, input().split()))
 
p_s.sort()
ans = 0
tmp_diff = float('inf')
 
for num in range(-300,301):
    if(num not in p_s):
        diff = abs(X - num)
        if (diff < tmp_diff):
            ans = num
            tmp_diff = diff
            
print(ans)

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

for i in range(102):
  if x-i not in p:
    print(x-i)
    break
  if x+i not in p:
    print(x+i)
    break

Solution (Python):
x, n, *P = map(int, open(0).read().split())
P = set(P)
for i in range(51):
    Q = {x-i, x+i} - P
    if Q:
        print(min(Q))
        break

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

Solution (Python):
x, n, *P = map(int, open(0).read().split())
for i in range(51):
	if x-i not in P:
		print(x-i)
		break
	if x+i not in P:
		print(x+i)
		break

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

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

	ans = -1
	mn = 10000

	for i in range(0, 102):
		if(p.count(i) == 0):
			d = x - i
			if d<0:
				d = -d
			if d<mn:
				ans = i
				mn = d
	print(ans)

Solution (Python):
import sys

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

sa = 300

for i in range(102):
    if abs(i-x) < sa:
        if not((i) in p):
            sa = abs(i-x)
            ans = i
print(ans)

Solution (Python):
x, n = map(int, input().split())
l = list(map(int, input().split()))
flg = False
t = x
while flg == False:
  if t in l:
    t -= 1
  else:
    ans = t
    flg = True
flg = False
t = x
while flg == False:
  if t in l:
    t += 1
  else:
    if abs(x-ans) > abs(x-t):
      ans = t
    flg = True
print(ans)

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

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

	ans = -1
	mn = 10000

	for i in range(-1, 102):
		if(p.count(i) == 0):
			d = x - i
			if d<0:
				d = -d
			if d<mn:
				ans = i
				mn = d
	print(ans)

Solution (Python):
x,n=map(int, input().split())
p = list(map(int, input().split()))
p=sorted(p)
last=1000
zettai=1000
for i in range(0, 102):
    if i not in p:
        if zettai>abs(i-x):
            zettai=abs(i-x)
            last=i
print(last)

Solution (Python):
X, N, *P = map(int, open(0).read().split())

cand = []
P = set(P)
for i in range(0, 102):
    if i in P:
        continue
    cand.append((abs(X - i), i))

cand.sort()

print(cand[0][1])

Solution (Python):
import sys






























fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())



x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x-i not in s):
		print(x-i)
		break
	elif(x+i not in s):
		print(x+i)
		break
	else:
		i+=1

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
Q = [q for q in range(-1, 102) if q not in P]
ans = min(Q, key=lambda q: (abs(q - X), q))
print(ans)

Solution (Python):

def main():
    X, _, *P = map(int, open(0).read().split())
    ans = min(set(range(-1, 102)) - set(P), key=lambda x: abs(X - x))
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
an = 0

 
  
for i in range(102):
    
    if p.count(i)==0:
        if abs(x-i)<wk:
            an =i
            wk = abs(x-i)

print(an)

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


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

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

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break

Solution (Python):
def main():

    x, n = map(int, input().split())
    ans = 0
    if n == 0:
        ans = x
        print(f'{ans}')
        exit()
    else:
        p = [int(i) for i in input().split()]

    for i in range(0, 102):
        if abs(x - i) not in p:
            ans = abs(x - i)
            break
        if x + i not in p:
            ans = x + i
            break
    
    print(f'{ans}')


if __name__ == '__main__':
    main()

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

for i in range(100):
    lr = [x - i, x + i]
    for y in lr:
        if y not in p:
            print(y)
            exit()

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

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

temp = x
d = 0

while 1:
    if temp - d not in p:
        print(temp - d)
        exit()
    if temp + d not in p:
        print(temp + d)
        exit()
    d += 1

Solution (Python):
x , n = map(int,input().split())
numberbuffer = 0
diff = 100000

if n == 0:
    print(x)
else:
    
    p = list(map(int,input().split()))
    
    pinverse = []
    
    for i in range(max(p)*2 +2):
        if (i-max(p)) not in p:
            pinverse.append(i-max(p))
        
    for y in pinverse:
        
        if abs(x-y) < diff:
            diff = abs(x-y)
            numberbuffer = y
        
        if diff == abs(x-y):
            if numberbuffer > y:
                numberbuffer = y
    
    print(numberbuffer)

Solution (Python):
def main():

    x, n = map(int, input().split())
    ans = 0
    if n == 0:
        ans = x
        print(f'{ans}')
        exit()
    else:
        p = [int(i) for i in input().split()]

    for i in range(n):
        if x - i not in p:
            ans = x - i
            break
        if x + i not in p:
            ans = x + i
            break
    
    print(f'{ans}')


if __name__ == '__main__':
    main()

Solution (Python):
x,n,*p=map(int,open(0).read().split())
i=0
while x in p:x+=(-1)**i*i;i+=1
print(x)

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

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

mn = 10**10
ans_li = []

for i in range(-200,201):
    if i not in p and abs(x - i) <= mn:
        ans_li.append(i)
        mn = abs(x - i)

for aa in ans_li:
    if abs(aa - x) == mn:
        print(aa)
        break

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

mn = 999
ans = 0

for i in range(0, 102):
    a = abs(X-i)
    if i not in p:
        if a < mn:
            mn = a
            ans = i

    if a > mn:
        break

print(ans)

Solution (Python):
import numpy as np

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

abslis = [[]for i in range(102)]*102
for n in range(N):
    abslis[abs(p[n]-X)].append(p[n])

if len(abslis[0]) == 0 :
    print(X)
else :
    
    
    for i in range(1,N+1):
        if len(abslis[i]) != 2: 
            if len(abslis[i]) == 0:
                print(X-i)
            elif len(abslis[i]) ==1:
                print( X+(X-abslis[i][0]) )   
            break

Solution (Python):
"""
int 
float 


a=input()
a,b=map(int,input().split()) 

print(a)
ptrint("Hello")

for name in fruits: 
    print(name)

list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1 = list(map(int, input().split()))　
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
abs(a) 
max(a,b) min(a,b) 

extension_1 = []
for i in range(10):
    extension_1.append(i)
extension_1


comprehension_1= [i for i in range(10)]
comprehension_1

"""
import math
import sys
X,N=map(int,input().split())
if N==0:
    print(X)
    sys.exit()
number = list(map(int, input().split()))
d =[0]*102
for i in number:
    d[i]=101
    
for j in range(102):
    if d[j]==101:
        continue
    d[j] = abs(X-j)
ans = min(d)
k=0
for l in range(102):
    if d[l]==ans:
        break
    k=k+1
print(k)

Solution (Python):
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,
                  log2, pi, radians, sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


x, n = invr()

mark = [0]*101
a = inlist()

lx = rx = res = x
while True:
    if lx not in a:
        res = lx
        break
    if rx not in a:
        res = rx
        break
    lx -= 1
    rx += 1
print(res)

Solution (Python):
x, n = map(int, input().split())
dic = {}
arr = list(map(int, input().split()))
for i in range(n):
    dic[arr[i]] = True
for i in range(1, 100):
    if x not in dic:
        print(x)
        break
    if x-i in dic:
        if x+i in dic:
            continue
        else:
            print(x+i)
            break
    else:
        print(x-i)
        break

Solution (Python):

def main():
    X, _, *P = map(int, open(0).read().split())
    P = set(P)
    for i in range(100):
        if X - i not in P:
            print(X - i)
            return
        if X + i not in P:
            print(X + i)
            return


if __name__ == "__main__":
    main()

Solution (Python):
x,n = map(int,input().split())
arr = list(map(int,input().split()))
l = x
r = x
while (l in arr and r in arr):
    l-=1
    r+=1
la = abs(x-l)
ra = abs(x-r)
if (la == ra):
    if (l not in arr):
        print(l)
        exit(0)
    if (r not in arr):
        print(r)
        exit(0)
else:
    if (la < ra):
        print(l)
        exit(0)
    else:
        print(r)
        exit(0)

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

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

Solution (Python):
X, N = map(int, input().split())
if N!=0:
    p=list(map(int,input().split()))
    checkNum=[0 for j in range(102)]
    for i in range(len(p)):
        checkNum[p[i]]=1
    i=0
    while(X-i>=0 or X+i<=101):
        if X-i>=0:
            if checkNum[X-i]==0:
                print(X-i)
                break
        if X+i<=101:
            if checkNum[X+i]==0:
                print(X+i)
                break
        i+=1
else:
    print(X)

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


all_l = [i for i in range(0,101)]
for p in P:
    all_l.remove(p)

kouho = x
for i in range(200):
    kouho1 = x-i
    kouho2 = x+i
    if kouho1 not in P:
        print(x-i)
        break
    elif kouho2 not in P:
        print(x+i)
        break

Solution (Python):
x, n = map(int, input().split())
if n == 0: print(x); exit()
P = [*map(int, input().split())]
for d in range(100): 
    a = x - d
    if a not in P: print(a); exit()
    a = x + d
    if a not in P: print(a); exit()

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

for diff in range(1000):
  if X - diff not in P:
    print(X - diff)
    break
  elif X + diff not in P:
    print(X + diff)
    break

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

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

Solution (Python):
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*200
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] != 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
      else:
        ans = A
      break
  print(ans)