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)
else:
  P = list(map(int,input().split()))
  hash_p = [0]*102
  for i in P:
    hash_p[i] += 1
  for i in range(N+1):
    if hash_p[X-i]==0:
      print(X-i)
      break
    if hash_p[X+i]==0:
      print(X+i)
      break

Solution (Python):
import numpy as np


def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

(X,N) = getVar()
p = getArray()

if (len(p) == 0):
  print(X)
else:
  subp = p - X
  i = 0
  while (True):
    if (not -i in subp):
      print(X - i)
      break
    if (not i in subp):
      print(X + i)
      break
    i += 1

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

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

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

Solution (Python):
import numpy as np

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

else:
    p = list(map(int, input().split()))
    main = set(np.arange(102))
    main = main - set(p)

    main1 = abs(np.array(list(main)))
    idx = abs(main1 - X).argmin()
    print(main1[idx])

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

dif = float("INF")
ans = 0

for i in range(102):
    if i not in lst:
        if dif>abs(i-x):
            dif = abs(i-x)
            ans = i
        elif dif==abs(i-x):
            ans = min(ans,i)

print(ans)

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))
ans = -1
d = float("inf")

for i in range(101, -1, -1):
    if i in p: continue
    c = abs(x-i)
    if c <= d:
        ans = i
        d = c

print(ans)

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

try:
  p = set(map(int, input().split()))
  num = set(range(-100,201))
  mem = []

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(item - X))
  
  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)

Solution (Python):
def main():
	a,b = map(int,input().split())
	h = list(map(int,input().split()))
	av = 0
	i = 1
	while av == 0:
		if b ==0:
			print(a)
			break
		elif a not in h:
			print(a)
			break
		plus = a+i
		minus = a-i
		if minus not in h:
			print(minus)
			av = 1
		elif plus not in h:
			print(plus)
			av = 1
		else:
			i += 1


if __name__ == '__main__':
	main()

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

diff = 0
while True:
    if (x - diff) not in p:
        ans = x - diff
        break
    elif (x + diff) not in p:
        ans = x + diff
        break
    else:
        diff += 1

print(ans)

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


diff = 0
while(True):
    if not x + diff in p:
        print(x+diff)
        sys.exit()

    if diff < 0:
        diff *= -1
    else:  
        diff *= -1
        diff -= 1

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

d, ans = 100000, -1
for i in range(-200, 200):
    if i in p:
        continue

    t = abs(i-x)
    if t < d:
        d = t
        ans = i
print(ans)

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

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

Solution (Python):
import numpy as np

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

p = np.array(list(map(int, input().split())))
for i in range(100):
    if not x-i in p:
        print(x-i)
        exit()
    elif not x+i in p:
        print(x+i)
        exit()

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

try:
  p = list(map(int,input().split()))
except EOFError:
  p = []

ab=10**18
ans=ab
for i in range(101):
  if not (x - i in p):
    print(x-i)
    break
  if not (x + i in p):
    print(x+i)
    break

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

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

dif = 0

while True:
  if (x - dif) not in nums:
    print(x - dif)
    break
  if (x + dif) not in nums:
    print(x + dif)
    break
  dif += 1

Solution (Python):
x,n = input().split()
x=int(x)
lst=input().split()
diff = 200
for i in range(-1, 102):
    if str(i) not in lst and abs(i-x) < diff:
        diff = abs(i-x)
        ans = i
print(ans)

Solution (Python):
x,n=input().split()
x=int(x)
n=int(n)
lst=input().split()
for i in range(0,n):
    lst[i]=int(lst[i])
if n==0:
    print(x)
else:
    minv=min(lst)
    maxv=max(lst)
    dis=100000

    for i in range(minv-2,maxv+3):
        if(i not in lst and abs(i-x)<dis):
            dis=abs(i-x)
            clv=i
            
    print(clv)

Solution (Python):
x,n = input().split()
x=int(x)
list=input().split()
diff = 200
for i in range(-1, 102):
    if str(i) not in list and abs(i-x) < diff:
        diff = abs(i-x)
        ans = i
print(ans)

Solution (Python):
x,n = input().split()
x=int(x)
n=int(n)
list=input().split()
for i in range(0, len(list)):
    list[i] = int(list[i])
diff = 200
for i in range(-1, 102):
    if i not in list and abs(i-x) < diff:
        diff = abs(i-x)
        ans = i
print(ans)

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

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

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

for i in range(n//2 +2):
    if x-i not in s:
        print(x-i)
        exit(0)
    if x+i not in s:
        print(x+i)
        exit(0)

Solution (Python):
x,n=map(int, input().split())
if n > 0:
  p=list(map(int,input().split()))
  for a in range(100):
    for b in [-1, 1]:
      u=x+a*b
      if not u in p:
        print(u)
        exit()
else:
  print(x)

Solution (Python):
x, n = map(int, input().split())
lst = []
if n > 0:
  lst = list(map(int, input().split()))
a = 100
b = 0

for i in range(0, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(b)

Solution (Python):
def main():
    x, n = map(int, input().rstrip().split(' '))
    if n == 0:
        print(x)
        return
    p = list(map(int, input().rstrip().split(' ')))
    if x not in p:
        print(x)
        return
    for i in range(1, 101):
        j, k = x - i, x + i
        
        if j not in p:
            print(j)
            return
        if k not in p:
            print(k)
            return
    
    

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 d in [-1,1]:
        a=x+i*d
        if not a in p:
            print(a)
            exit()

Solution (Python):

import sys
input = lambda: sys.stdin.readline().strip()
x, n = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
for i in reversed(range(0, x + 1)):
    if i not in p:
        lt = i
        break
for i in range(x + 1, 102):
    if i not in p:
        gt = i
        break
print(lt if abs(lt - x) <= abs(gt - x) else gt)

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(x+1):
    for j in [-1, +1]:
        num = x+i*j
        if num not in p:
            print(num)
            exit()

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

ans = x
if ans in lst:
    pass
else:
    print(ans)
    exit()

left,right = ans-1,ans+1

while True:
    if left in lst and right in lst:
        left -=1
        right += 1

    elif left in lst:
        print(right)
        exit()

    else:
        print(left)
        exit()

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

min_value = 101
v = 0

if X in lst:
  for i in range(200):
    if not (i in lst):
      if abs(X - i) < min_value:
        min_value = abs(X - i)
        v = i
else:
  v = X
       

print(v)

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

minv=101
v=0

if X in P:
  for i in range(200):
    if not(i in P):
      if abs(X-i) < minv:
        minv=abs(X-i)
        v=i
else:
  v=X
       

print(v)

Solution (Python):
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
out=0
for i in range(0,1000):
  out=0
  for j in range(n):
    if slist[j]==x-i:
      out=1
  if out !=1:
   print(x-i)
   exit()
  out=0
  for k in range(n):
    if slist[k]==x+i:
      out=1
  if out !=1:
    print(x+i)
    exit()

Solution (Python):




import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(x, n, p_liste):
    if n == 0:
        return x
    
    if x not in p_liste:
        return x
    chikai = x-1
    plus = x + 1

    for _ in range(0,101):
        
        if chikai not in p_liste:
            return chikai
        elif plus not in p_liste:
            return plus
        else: 
            plus += 1
            chikai -= 1
    return "問題"

def çözmek():
    X,N = map(int,sys.stdin.readline().split())
    P_liste = list(map(int, sys.stdin.readline().split()))

   
    res = []
    res.append(関数(X,N,P_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()

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):
import sys
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)
            sys.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(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 150):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -150, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)

Solution (Python):
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
  
for i in range(100):
  if N-i not in A:
    print(N-i)
    exit()
  elif N+i not in A and N+i!=N-i:
    print(N+i)
    exit()

Solution (Python):
x,n = map(int, input().split())
p = set(map(int, input().split()))
ans = set(range(102))
ans = sorted(list(ans - p))
now = 110
a = 0
for i in ans:
  if abs(x-i) < now:
    a = i
    now = abs(x-i)
print(a)

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

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

n=set(n for n in range(-100,102))

pd=list(n-p)

min1=1000

for i in range(len(pd)):
    if abs(pd[i]-x)<abs(min1-x):
        min1=pd[i]
    elif abs(pd[i]-x)==abs(min1-x):
        min1=min(pd[i],min1)
print(min1)

Solution (Python):
x,n = map(int, input().split())
seisuu_list = list(map(int, input().split()))
seisuu_list.sort()
if seisuu_list == []:
    print(x)


for i in range(1,n+1):
    if i%2 != 0:
        i = -1*i
    
    if x in seisuu_list:
        x += i
        if x in seisuu_list:
            continue
        else:
            print(x)
            exit()
    else:
        print(x)
        break

Solution (Python):

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

for i in range(0, x+100):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break
    else:
        continue
    break


print(ans)

Solution (Python):
X, N = map(int, input().split())
A = []
if N != 0:
  A = list(map(int, input().split()))
dp = [abs(X-i) for i in range(102)]
for i in range(N):
  dp[A[i]] = int(1e18)
m = int(1e18)
M = 102
for i in range(102, 0, -1):
  if m >= dp[i-1]:
    m = dp[i-1]
    M = i - 1
print(M)

Solution (Python):
import math
X,N = map(int, input().split())
p = list(map(int, input().split()))
i = 0
while 1:
    if (X-i in p) == False:
        print(X-i)
        break
    elif (X+i in p) == False:
        print(X+i)
        break
    i += 1

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


m = 100
ans=100

for i in  range(0,103):
    if(i in p):
        continue

    elif(abs(i-x) < m):
        m = abs(i-x)
        ans = i

print(ans)

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):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(-1000, 1000)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)

Solution (Python):
x, n = map(int, input().split())
lst = list(map(int, input().split()))
is_exist = [False] * 120
for i in lst:
    is_exist[i] = True
ans = 0
diff = 0
while True:
    if is_exist[x - diff] == False:
        ans = x - diff
        break
    elif is_exist[x + diff] == False:
        ans = x + diff
        break
    diff += 1
print(ans)

Solution (Python):
x, n = map(int, input().split())
try:
  list_P = [int(p) for p in input().split()]
  list_not_P = [x for x in range(102) if not x in list_P]
  list_abs = [abs(x - i) for i in list_not_P]
  Index = list_abs.index(min(list_abs))
  print(list_not_P[Index])
except EOFError:
  print(x)

Solution (Python):
X,N = map(int,input().split())
l = list(map(int,input().split()))
n_l = sorted(l)

for i in range(100):
  if not X-i in n_l:
      print(X-i)
      break
  elif not X+i in n_l:
      print(X+i)
      break
  pass

Solution (Python):
x,n= map(int,input().split(' '))
if n!=0:
    arr= list(map(int,input().split(' ')))
    for j in range(x+1):
        for i in range(-1,2):
            if arr.count(x+i*j)==0:
                print(x+i*j)
                exit(0)
else:
    print(x)

Solution (Python):
x,n=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]
ele=set()
for i in arr:
    ele.add(i)
left=x
rigth=x
while True:
    if rigth not in ele and left not in ele:
        print(min(rigth,left))
        break
    if left not in ele:
        print(left)
        break
    if rigth not in ele:
        print(rigth)
        break
    left-=1
    rigth+=1

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

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

Solution (Python):
X, N = list(map(int, input().split()))
if N != 0:
    p = list(map(int, input().split()))
if N == 0:
    p = []
if X in p:
    Xp = X + 1
    Xm = X - 1
    while True:
        if Xm in p:
            Xm -= 1
        else:
            print(Xm)
            break
        if Xp in p:
            Xp += 1
        else:
            print(Xp)
            break
else:
    print(X)

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

for i in range(x+1):
    for j in [-1,+1]:
        a = x + j * i
        if p.count(a) == 0:
            print(a)
            exit(0)

Solution (Python):
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(103)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i] = 1

for i in range(0, 102):
    temp_abs = abs(x-i)
    if n_abs > temp_abs and p_list[i] != 1:
        n_abs = temp_abs
        ans = i

print(ans)

Solution (Python):
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(100)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i-1] = 1

for i in range(0, 102):
    if i == 0 or i == 101:
        temp_abs = abs(x-i)
        if n_abs > temp_abs:
            n_abs = temp_abs
            ans = i
    else:
        temp_abs = abs(x-i)
        if n_abs > temp_abs and p_list[i-1] != 1:
            n_abs = temp_abs
            ans = i
        elif n_abs == temp_abs and i < ans and p_lsit[i-1] != 1:
            n_abs = temp_abs
            ans = i

print(ans)

Solution (Python):
def MI():
    return map(int, input().split())

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

X, N = MI()
P = LI()
ans = X

if len(P) == 0:
    print(ans)
    exit()

for i in range(101):
    if not X - i in P:
        ans = X - i
        break
        
    if 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()))

for d in range(x + 1):
    if (x - d) not in p:
        print(x-d)
        exit()

    elif (x + d) not in p:
        print(x+d)
        exit()

Solution (Python):
X,N = map(int,input().split())
p = sorted(list(map(int,input().split())))
for i in range(X,-1,-1):
    if i not in p:
        ans = i
        break
for i in range(X+1,102):
    if i not in p:
        ans2 = i
        break
if X-ans > ans2-X:
    print(ans2)
else:
    print(ans)

Solution (Python):
x,n=map(int,input().split())
g=set(map(int,input().split()))
l=r=x
while 1:
    if l in g:l-=1
    else:print(l);break
    if r in g:r+=1
    else:print(r);break

Solution (Python):
import sys
X, N = 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 a not in p:
            print(a)
            exit(0)

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))
min_d = 103
ans = 103
for i in range(102):
    if i in p:
        continue
    d = abs(x - i)
    if d < min_d:
        min_d = d
        ans = i
print(ans)

Solution (Python):
x,n = map(int,input().split())
p = input().split()
q = p[::-1]
a = x
b = x
c = 1
if p.count(str(x)) == 1:
  while c == 1:
    a -= 1
    c = p.count(str(a))
c = 1
if p.count(str(x)) == 1:
  while c == 1:
    b += 1
    c = p.count(str(b))
if x - a <= b - x:
  print(a)
else:
  print(b)

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

for d in range(X + 1):
    if (X - d) not in p:
        print(X-d)
        exit()
    elif (X + d) not in p:
        print(X+d)
        exit()

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
P = [int(i) for i in input().split()]
P = sorted(P)
diff = abs(x-(P[0]-1))
ans = P[0]-1
for i in range(1, 102):
  if i not in P and abs(x-i) < diff:
    diff = abs(x-i)
    ans = i
print(ans)

Solution (Python):
from sys import exit, stdin
X, N = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(X+1):
    diff = [X-i, X+i]
    if diff[0] not in P:
        ans = diff[0]
        break
    if diff[1] not in P:
        ans = diff[1]
        break
print(ans)

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

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

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

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    X, N = MI()
    P = LI()

    ans = 0
    d = INF
    for i in range(0, 102):
        if i in P: continue
        if d > abs(i - X):
            ans = i
            d = abs(i - X)
    print(ans)

if __name__ == '__main__':
    solve()

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

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

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

diff = 0

while True:
    if x - diff not in pn:
        print(x-diff)
        exit()
    elif x + diff not in pn:
        print(x+diff)
        exit()
    diff += 1

Solution (Python):


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

if n == 0:
    p = set([])
else:
    p = list(map(int, input().split()))
a = list(set(range(201)) - set(p))
abs_diff = [abs(i - x) for i in a]
min_abs_diff = min(abs_diff)
for i, j in zip(a, abs_diff):
    if j == min_abs_diff:
        print(i)
        break

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

for i in range(0,100):
    if x - i not in P:
        print(x-i)
        exit()
    elif x + i not in P:
        print(x+i)
        exit()

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

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


for i in range(100):
    num = x-i
    if num not in p:
        print(num)
        exit()
    num = x+i
    if num not in p:
        print(num)
        exit()

Solution (Python):
import math


def main():
    a, b = map(int, input().split())
    array = list(map(int, input().split()))

    cnt = 1
    ans = 0
    array2 = []
    zero_flg = 0

    if len(array) != 0:
        for i in range(len(array)):
            if a == array[i]:
                zero_flg = 1

    if zero_flg == 0:
        ans = a
    else:
        if ans == 0:
            while True:
                for i in range(len(array)):
                    if (a + cnt == array[i]) or (a - cnt == array[i]):
                        array2.append(array[i])
                if len(array2) != 2:
                    break
                cnt += 1
                array2.clear()

        if len(array2) == 0:
            if a + cnt < a - cnt:
                ans = a + cnt
            else:
                ans = a - cnt
        elif len(array2) == 1:
            if array2[0] == a + cnt:
                ans = a - cnt
            else:
                ans = a + cnt

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    x,n = map(int, input().split())
    p_list = list(map(int, input().split()))
    x_list = [i for i in range(0,200)]
    ans = 0
    min_abs = 10**3

    for i in p_list:
        x_list.remove(i)

    for j in x_list:
        if min_abs > abs(j-x):
            min_abs = abs(j-x)
            ans = j

    print(ans)
    
    

   
if __name__ == "__main__":
    main()

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

def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))
    if X not in p:
        print(X)
        return
    for i in range(1, 101):
        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())
p=list(map(int,input().split()))
c=0
if n==0:
    print(x)
else:
    while True:
        if x-c not in p:
            print(x-c)
            break
        elif x+c not in p:
            print(x+c)
            break
        c+=1

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

try:
    p = [None if k is None else int(k) for k in input().split()]
except:
    p = []
i = 0
while True:
    if not x - i in p:
        print(x - i)
        break
    if not x + i in p:
        print(x + i)
        break
    i += 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)
    break
  if X+count not in P:
    print(X+count)
    break
  count+=1

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
for i in range(100):
    pFlag = True
    mFlag = True
    for j in range(len(p)):
        if p[j] == x+i:
            pFlag = False
        if p[j] == x-i:
            mFlag = False
    if mFlag:
        a = (-1)* i
        break
    if pFlag:
        a = i
        break
print(x+a)

Solution (Python):
def myargmin(array):
    array = list( array )
    return array.index(min(array))

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

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

    P = sorted(map(int, input().split(" ")))
    array = list(range(0, 102))
    for p in P:
        if p in array:
            array.remove(p)
        else:
            continue

    resid = [abs(a - X) for a in array]
    min_idx = myargmin(resid)

    print(array[min_idx])

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



for j in range(0,X+1):

    flag_a=0
    flag_b=0

    a=X-j
    b=X+j

    for k in p:

        if a==k:
            flag_a=1
        if b==k:
            flag_b=1

    if flag_a==0:

        print(a)
        break
    
    elif flag_b==0:

        print(b)
        break

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

if N == 0:
    print(X)
    exit()
else:
    for i in range(200):

        if X-i not in nums:
            print(X-i)
            exit()

        if X+i not in nums:
            print(X+i)
            exit()

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


ans_list = []
for i in range(102):
    ans_list.append([abs(X-i),i])
ans_list = sorted(ans_list)
flag = True
for j in range(102):
    for k in range(N):
         if(p[k]==ans_list[j][1]):
             flag = False
    if(flag):
        print(ans_list[j][1])
        break
    flag = True

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

Solution (Python):
xn = list(map(int, input().split()))
if xn[1] == 0:
  print(xn[0])
  exit()
  
p = list(map(int, input().split()))

flag = 0
abs = 0

while flag == 0:
  test1 = xn[0] + abs
  test2 = xn[0] - abs
  if not test2 in p:
    flag = 2
  elif not test1 in p:
    flag = 1
  abs += 1

if flag == 1:
  print(test1)
else:
  print(test2)

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


diff = 10000
best = -1
for i in range(-100, 201):
    if i not in P:
        d = abs(X-i)
        if diff > d:
            best = i
            diff = d
            
print(best)

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

set_p = set(p)

num = 2000
ans = 0
for i in range(200, -1 , -1):
    if i not in set_p:
        if num >= abs(x - i):
            num = abs(x - i)
            ans = i

print(ans)

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

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

x = X
while x in P:
  x -= 1
minX = x

x = X
while x in P:
  x += 1
maxX=x

if abs(minX - X) <= abs(maxX - X):
  print(minX)
else:
  print(maxX)

Solution (Python):
X, N = map(int, input().split())
if N == 0:
        print(X)
else:
        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):
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p-1)
    sys.exit()
p = list(map(int,input().split()))  
MIN = 101   
minnum = 0
for i in range(-101,102):
    if not i in p:
        if abs(i-X) < MIN:
            MIN = abs(i-X)
            minnum = i
print(minnum)

Solution (Python):
X, N = map(int, input().split(' '))
P = []
if N > 0:
  P = sorted(list(map(int, input().split(' '))))
  ans = 0
  i = 0
  while True:
    if (X-i) not in P:
      ans = (X-i)
      break
    elif (X+i) not in P:
      ans = (X+i)
      break
    else:
      i += 1

if N > 0:
  print(ans)
else:
  print(X)

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

p = list(map(int, input().split()))
i = 1
if x in p:
  while 1:
    if (x - i) in p:
      if (x + i) in p:
        i += 1
      else:
        print(x + i)
        sys.exit()
    else:
      print(x - i)
      sys.exit()
else:
  print(x)