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):
import sys
import time


import bisect

import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
x,n = rl()
p=rl()
p.sort()
for i in range(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 = [int(n) for n in input().split()]

P = set(int(n) for n in input().split())

closest = float('inf')
diff = float('inf')

for p in range(-1,102):
    if not p in P and abs(X - p) < diff:
        closest = p
        diff = abs(X - p)

print(closest)

Solution (Python):
X, N = map(int, input().split())
P = set(list(map(int, input().split())))
res = (0, 1000)
for i in range(102):
    if i in P:
        continue
    if abs(X - i) < res[1]:
        res = (i, abs(X - i))
print(res[0])

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

tmp=1000
ans=1000

for i in range(101,-1,-1):
    if abs(i-X)<=tmp and i not in p:
        tmp=abs(i-X)
        ans=i

print(ans)

Solution (Python):
x,n=map(int,input().split())
if n!=0:
  p=list(map(int,input().split()))
else:
  print(x)
  exit()
  
def arimasuka(num,sign):
  if num in p:
    k=arimasuka(num+sign,sign)
  else:
    return num
  return k

p.sort()
ans1=arimasuka(x,1)
ans2=arimasuka(x,-1)
if abs(ans1-x)>=abs(ans2-x):
  print(ans2)
  exit()
else:
  print(ans1)
  exit()

Solution (Python):
X, N = [int(i) for i in input().split(' ')]
p_str = input()
p = [] if len(p_str) == 0 else [int(i) for i in p_str.split(' ')]

sorted(p)

j = 0 
while True:
  a = p.count(X+j)
  b = p.count(X-j)
  if b == 0:
    ans = X - j
    break
  if a == 0:
    ans = X + j
    break 
  j += 1

print(ans)

Solution (Python):

import sys

sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)











def run():
    X, N = map(int, input().split())
    P = list(map(int, sysread().split()))
    exist = [False] * 201
    for p in P:
        exist[p] = True
    resid = 0

    while True:
        if not exist[X - resid]:
            print(X - resid)
            return None
        if not exist[X + resid]:
            print(X+resid)
            return None
        resid += 1


if __name__ == "__main__":
    run()

Solution (Python):
x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))
  pp = set(p)
  ans = 200
  cnt = 0
  for i in range(102):
    if i in pp:
      continue
    if ans > abs(x-i):
      ans = abs(x-i)
      cnt = i
  print(cnt)
else:
  print(x)

Solution (Python):
def main():
    X,N = map(int, input().split())
    l = [int(x) for x in input().split()]
    
    ans=0
    if N == 0:
        ans = X
    
    for i in range(100000):
        if not (X-i in l):
            ans=X-i
            break
        elif not(X+i in l):
            ans=X+i
            break
    print(ans)
main()

Solution (Python):
x, n = map(int, input().split())
P = set(list(map(int, input().split())))
ans = 0
diff = x
for a in range(102):
    if a not in P:
        tmp = abs(a-x)
        if diff > tmp:
            diff = tmp
            ans = a
print(ans)

Solution (Python):
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    x = kwargs["x"]
    n = kwargs["n"]
    P = kwargs["P"]

    for i in range(len(P)):
        P[i] -= x

    res = 0

    while True:
        if not res in P:
            break

        res *= -1

        if not res in P:
            break

        res *= -1

        res -= 1

    res += x
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["x"], kwargs["n"] = [int(i) for i in cin]
    cin = input().split()
    kwargs["P"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Solution (Python):
x,n = map(int, input().split())
if n == 0:print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    ans = 10**9
    flag = False
    for i in range(1000):
        for j in range(n):
            if not x - i in p:
                print(x - i)
                flag = True
                break
            if x + i in p:continue
            else:
                print(x + i)
                flag = True
                break
        if flag:break

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

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

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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False



def main():
    X, K = MI()
    p = LI()
    diff = []
    ps = set(p)
    c = []

    for i in range(-100, 200):
        if i not in ps:
            c.append(i)

    for i in range(len(c)):
        n = (abs(c[i] - X), i)
        diff.append(n)

    diff.sort()

    

    if len(diff) == 0:
        print(X)
    elif len(diff) == 1:
        print(c[diff[0][1]])
    elif len(diff) > 1:
        if diff[0][0] == diff[1][0]:
            a = c[diff[0][1]]
            b = c[diff[1][1]]
            print(min(a, b))
        else:
            a = c[diff[0][1]]
            print(a)


if __name__ == '__main__':
    main()

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

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

ls = [i for i in range(102)]
for i in pn:
    ls[i] = 0

ls = list(set(ls))
ans = 0
m = 10**5
for j in ls:
    if abs(x - j) < m:
        m = abs(x - j)
        ans = j

print(ans)

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

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

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
zettaiti = float("inf")
for i in range(102):
    if i not in p:
        zettaiti2 = abs(i - x)
        if zettaiti > zettaiti2:
            zettaiti = zettaiti2
            ans = i
print(ans)

Solution (Python):
x, n = map(int, input().split())
P = list(map(int, input().split()))
ans = 101
d = ans - x
for i in range(100, -1, -1):
    if i not in P:
        if abs(x-i) <= d:
            d = abs(x-i)
            ans = i
print(ans)

Solution (Python):
def LI():return list(map(int,input().split()))
def MI():return map(int,open(0).read().split())
def I():return int(input())
def yes():print("Yes")
def no():print("No")



INF=float("inf")




x,n=LI()
if n==0:
    print(x)
    exit()
p=LI()
p.sort()

ans=-1
tmp=INF
for i in range(-100,200):
    if i in p:continue
    k=abs(i-x)
    if k<tmp:
        tmp=k
        ans=i
    
print(ans)

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

  i=0
  while True:
    koho1=x-i
    koho2=x+i
    if not (koho1 in p_list):
      ans=koho1
      break
    if not (koho2 in p_list):
      ans=koho2
      break
    i=i+1
  print(ans)

Solution (Python):
def main() :
    X,N = map(int,input().split())
    P_list = [int(i) for i in input().split()]
    P_set = set(P_list)

    
    
    

    distance = 0
    while(True) :
        ck = X - distance
        if (ck not in P_set) :
            print(ck)
            return
        
        ck = X + distance
        if (ck not in P_set) :
            print(ck)
            return
        
        distance += 1

main()

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

now=0
for i in range(102):
    if i not in p:
        if abs(x-now)>abs(x-i):
            now=i
    
print(now)

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

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

S_ans = X
L_ans = X

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

Solution (Python):
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    X, N = MI()
    p = LI()
    W = X
    Y = X


    while True:

        if (W not in p)and (Y not in p):
            ans = W
            break
        elif (W not in p) and (Y in p):
            ans = W
            break
        elif (W in p) and (Y not in p):
            ans = Y
            break
        W -= 1
        Y += 1 
    print(ans)


    
    print()

if __name__ == "__main__":
	main()

Solution (Python):



import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    X, N = i2nn()
    if N == 0:
        print(X)
        return
    p = set(i2nn())
    for i in range(101):
        if X - i not in p:
            print(X - i)
            return
        if X + i not in p:
            print(X + i)
            return

    return

main()

Solution (Python):
import bisect

X, N = map(int, input().split())
if N > 0:
  Ps = list(map(int, input().split()))
else:
  Ps = []

Pst = set(Ps)

ab = 200
tmp = 200
rlt = -1
for i in range(102):
  if i in Pst:
    continue
  else:
    tmp = abs(i-X)
    if ab > tmp:
      ab = tmp
      rlt = i
      
print(rlt)

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

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

p=sorted(p)

dist=10*9
ans=102
for i in range(102,-2,-1):
    if abs(x-i)<=dist and i not in p:
        dist = abs(x-i)
        ans = i
        if i<=ans:
            ans = i
        

print(ans)

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools









X,N = map(int,input().split())
p = [str(i) for i in input().split()]
ans = 0
flag = 1


for i in range(100):
  if(str(X-i) in p):
    pass
  else:
    ans = X-i
    break
  if(str(X+i) in p):
    pass
  else:
    ans = X+i
    break

print(ans)

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

if X not in P:
    print(X)
    exit()

count = 1
while True:
    minus = X - count
    if minus not in P:
        print(minus)
        exit()

    plus = X + count
    if plus not in P:
        print(plus)
        exit()

    count += 1

Solution (Python):

X,N = map(int, input().split())
P = list(map(int, input().split()))
for i in range(0,110):
    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:
  print(x)
else:
  p=list(map(int,input().split()))
  p.sort()
  ans=0
  on=1
  dif=1
  if x in p:
    now=p.index(x)
    while on==1:
      if now-dif<0:
        ans=x-dif
        on=0
      elif p[now-dif]!=x-dif:
        ans=x-dif
        on=0
      elif now+dif==n:
        ans=x+dif  
        on=0
      elif p[now+dif]!=x+dif:
        ans=x+dif
        on=0
      else:
        dif+=1
    print(ans)
  else:
    print(x)

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

def check(l, m):
    flag = True
    for i in l:
        if i == m:
            flag = False
            break
    return flag

if check(p, s):
    print(s)
    exit()
if check(p, t):
    print(t)
    exit()

while True:
    s = s - 1
    t = t + 1
    
    if check(p, s):
        print(s)
        exit()
    if check(p, t):
        print(t)
        exit()

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
a=[0 for i in range(102)]
for i in range(n):
    a[p[i]]+=1
k=0
while True:
    if a[x-k]==0:
        print(x-k)
        break
    
    if a[x+k]==0:
        print(x+k)
        break
    k+=1

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

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

    d = 1
    while True:
        a = x - d
        if a not in P:
            print(a)
            exit()

        a = x + d
        if a not in P:
            print(a)
            exit()

        d += 1


if __name__ == '__main__':
    main()

Solution (Python):
X, N = map(int, input().split())
if N != 0:
    P = [int(i) for i in input().split()]
else:
    P = []
m = float("inf")
ans = 0
l = set(range(-1000, 1001)) - set(P)
for p in sorted(l):
    d = abs(p-X)

    if d < m:
        m = d
        ans = p

print(ans)

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

Solution (Python):
X, N = map(int,input().split())
p = list(map(int,input().split()))
hoge = {}
for i in p:
    hoge[i] = 1

m = X
while m in hoge:
    m -= 1
p = X
while p in hoge:
    p += 1
if p-X < X-m:
    print(p)
else:
    print(m)

Solution (Python):
def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    P.sort()
    ans = 10000
    value = 100000
    for i in range(-1000,1000):
        if i in P:
            continue
        if ans > abs(X - i):
            ans = abs(X-i)
            value = i

    print(value)
            




if __name__ == "__main__":
    main()

Solution (Python):
x,n=map(int,input().split())
if n==0:
	print(x)
	exit()
p=list(map(int,input().split()))
s=x-1
b=x+1
if x not in p:
	print(x)
else:
	while True:
		if s not in p:
			print(s)
			exit()
		s-=1
		if b not in p:
			print(b)
			exit()
		b+=1

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

if abs(ans2-x) < abs(ans1-x):
    print(ans2)
elif abs(ans2-x) > abs(ans1 - x):
    print(ans1)
else:
    print(min(ans1,ans2))

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X, N = il()
    P = il()

    ret = 0
    s = MAX
    for n in range(-101, 102):
        if n not in P and abs(X-n) < s:
            s = abs(X-n)
            ret = n
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
X,N = map(int,input().split())
if N != 0:
    P = list(map(int,input().split()))
if N == 0:
    P = [3.2]
judge = P[0]
if X not in P:
    print(X)
plusminus = 0
if X in P:
    while True:
        plusminus +=1
        if X-plusminus not in P:
            
            print (X-plusminus)
            break
        elif X+plusminus not in P:
            print(X+plusminus)
            break

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

import sys
if n==0:
    print(x)
    sys.exit()
p=list(map(int,input().split()))
if x not in p:
    print(x)
    sys.exit()
min=x
max=x

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

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

p.sort()
def main():
    l = [True for _ in range(100)]
    for x in p:
        l[x-1] = False
    diff = 0
    while True:
        if X-1 -diff < 0:
            print(0)
            return
        elif l[X-1 -diff]:
            print(X -diff)
            return
        elif X-1 +diff >= 100:
            print(101)
            return
        elif l[X-1 +diff]:
            print(X +diff)
            return
        diff += 1

main()

Solution (Python):
x, n = map(int, input().split())
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):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int, input().split()))
ans = -float('inf')
d = float('inf')
for i in range(-10, 2100):
  if i not in p:
    if abs(X-i) < d:
      d = abs(X-i)
      ans = i

print(ans)

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

ans = 0
tmpabs = 150

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

for i in range(110):
    if i not in P and tmpabs > abs(X-i):
        ans = i
        tmpabs = 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()))

Sa = []

Ba = list(range(-1, 102))
Cha = list(range(-1, 102))

for i in range (0, N):
	if Ba.count(P[i]) > 0:
		Cha.remove(P[i])

Denbaba = len(Cha)

for i in range (0, Denbaba):
	Sa.append(abs(Cha[i]-X))

Da = min(Sa)

for i in range (0, Denbaba):
	if Sa[i] != Da:
		Cha[i]=1000000


print(min(Cha))

Solution (Python):
a,b = map(int,input().split())
z = list(map(int,input().split()))
if a in z:
	j =1
	while True:
		if (a-j) not in z:
			print(a-j)
			break
		if a+j not in z :
			print(a+j)
			break
		j+=1
else:
	print(a)

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

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
k = True
if not x in p:
    print(x)
else:
    y = x
    z = x
    while k:
        y -= 1
        if not y in p:
            print(y)
            break
        z += 1
        if not z in p:
            print(z)
            break

Solution (Python):

import sys


def solve(X: int, N: int, p: "List[int]"):
    if N == 0:
        print(X)
        return
    
    arr = [0 for _ in range(102)]

    for i in p:
        arr[i] = 1
    
    i = 0
    while True:
        if not arr[X - i]:
            print(X - i)
            return
        elif not arr[X + i]:
            print(X + i)
            return
        i += 1
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    N = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(X, N, p)

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


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

ans = 10000
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())
if N > 0:
    p = list(map(int, input().split()))
    for i in range(100):
        now_p = X+i
        now_m = X-i
        if not now_m in p:
            ans=now_m
            break
        elif not now_p in p:
            ans = now_p
            break
else:
    ans = X

print(ans)

Solution (Python):
x, n = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr.append(n)
arr = set(arr)
a = 0
ans = 0
while True:
    if (x - a) not in arr:
        ans = x-a
        break
    if (x + a) not in arr:
        ans = x+a
        break
    a += 1
print(ans)

Solution (Python):
def resolve():
    X, N = [int(i) for i in input().split()]
    if N == 0:
        print(X)
        return
    P = sorted([int(i) for i in input().split()])
    if X not in P:
        print(X)
        return
    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


resolve()

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

if N != 0:
    p = [int(i) for i in input().split()]

ans = 0
if N == 0:
    ans = X
else:

    for i in range(N):
        key = X - i

        if key in p:
            pass
        else:
            ans = key
            break

        key = X + i

        if key in p:
            pass
        else:
            ans = key
            break

print(ans)

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

if n == 0 or not x in p:
    print(x)
    sys.exit()
c = 1
while True:
    if not x-c in p:
        print(x-c)
        sys.exit()
    if not x+c in p:
        print(x+c)
        sys.exit()
    c+=1

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

ans = X
for i in range(101):
    a = X + i
    b = X - i
    if a not in P_set:
        ans = a
        if b not in P_set:
            ans = b
        break
    if b not in P_set:
        ans = b
        break
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X, N = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]

    if N == 0:
        print(X)
        return

    sa = 10000
    ans = []
    for i in range(-100, 102):
        if i in P:
            continue

        tmpans = sa
        sa = min(sa, abs(X - i))
        ans.append([sa, i])


    ans.sort()
    print(ans[0][1])



if __name__ == '__main__':
    main()

Solution (Python):
x,n = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
if P:
    for i in range(1,300):
        if i not in P:
            if abs(x-i) < abs(x-ans):
                ans = i
else:
    ans = x

print(ans)

Solution (Python):
x,n,*a=map(int,open(0).read().split())
b=[1]*103
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)

Solution (Python):
import sys
a=input()
a0=a.split()
x=int(a0[0])
n=int(a0[1])
if n==0:
    print(x)
    sys.exit()
p=input()
pl=list()
p=p.split()
k=-1
for i in range(n):
    pl.append(int(p[i]))
for i in range(102):
    q=i in pl
    if q==False :
        if abs(i-x)<abs(k-x):
            k=i
        else:
            print(k)
            sys.exit()
print(k)

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

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

Solution (Python):

def main():
  x, n = list(map(int, input().split()))
  if n == 0:
    print(x)
    exit()
  pp = list(map(int, input().split()))
  
  i = 0
  while True:
    if x-i not in pp:
      print(x-i)
      exit()
    if x+i not in pp:
      print(x+i)
      exit()
    i += 1
  
  
if __name__ == "__main__":
  main()

Solution (Python):
import sys

input = sys.stdin.readline
x, n = map(int, input().split())
p = list(map(int, input().split()))
for i in range(100):
    s = x - i
    e = x + i
    if p.count(s) == 0:
        print(s)
        break
    elif p.count(e) == 0:
        print(e)
        break

Solution (Python):
x,n=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
np=[i for i in range(0,200) if not i in p]
r=0
for i in np:
    if abs(x-i)<abs(x-r):
        r=i
print(r)

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

pinv=[True for i in range(102)]

for i in p:
    pinv[i]=False

ab=1000
ans=-1
for i in range(102):
    if (i<0 or pinv[i]) and abs(x-i)<ab:
        ab=abs(x-i)
        ans=i

print(ans)

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

def get_result():
    for i in range(100):
        a = X - i
        b = X + i
        if not a in P:
            return a
        if not b in P:
            return b

print(get_result())

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

if X not in p:
    print(X)
else:
    for i in range(100):
        if (X - (i + 1)) not in p:
            print(X - (i + 1))
            break
        elif (X + (i + 1)) not in p:
            print(X + (i + 1))
            break

Solution (Python):
x,n=map(int,input().split())
if n!=0:
    p=list(map(int,input().split()))
    L=[i for i in range(102) if i not in p]
    l=[abs(i-x) for i in L]
    key=l.index(min(l))
    print(L[key])
else:
    print(x)

Solution (Python):
import sys
x,n=map(int,input().split())
if n==0:
  print(x)
  sys.exit()
b=list(map(int,input().split()))
a=list(range(-1,102))
for i in b:
  a.remove(i)
mn=1000
j=1000
for i in a:
  c=abs(x-i)
  if c<mn:
    j=i
    mn=c    
  elif c==mn:
    j=min(j,i)
print(j)

Solution (Python):

import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')


REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn


TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        X, N = map(int, self.input_data().split())
        if N == 0:
            p = []
        else:
            p = list(map(int, self.input_data().split()))

        result = [0,200]
        for i in range(0, 200):
            if i in p:
                continue
            if abs(X-i) < result[1]:
                result[0] = i
                result[1] = abs(X-i)
            elif abs(X-i) == result[1] and i < result[0]:
                result[0] = i

        print(str(result[0]))

solver = Solver(REL_PATH)
solver.exec_resolve()

Solution (Python):
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

def main():
    x,n = inpl()
    Pls = inpl()

    for k in range(100):
        if x-k not in Pls:
            print(x-k)
            return
        elif x+k not in Pls:
            print(x+k)
            return
main()