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, *lst = map(int, open(0).read().split())
for i in range(x + 1):
  if x - i not in lst:
    print(x - i)
    quit()
  if x + i not in lst:
    print(x + i)
    quit()

Solution (Python):


X,N=map(int,input().split())
p=list(map(int,input().split()))
q=[]
for i in range(0,102):
    if i not in p:
        q.append(i)
R=len(q)
M= [ [ q[i],abs(q[i]-X)] for i in range(R)]

M.sort(key=lambda x:x[0])
M.sort(key=lambda x:x[1])
print(M[0][0])

Solution (Python):















mod = int(1e9+7)

INF = 1<<50

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

def main():
    x,n = readInt()
    if not n:
        print(x)
        return
    p = readInt()
    p.sort()
    res_min = 0
    for i in range(100):
        if x-i not in p:
            res_min = max(x-i,res_min)
    res_max = INF
    for i in range(100):
        if x+i not in p:
            res_max = min(x+i,res_max)
    if (x-res_min)<=(res_max-x):
        print(res_min)
    else:
        print(res_max)
    return

if __name__=='__main__':
    main()

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    P = list(map(int, input().split()))
    check = 0
    while True:
        if not X-check in P:
            print(X-check)
            return
        if not X+check in P:
            print(X+check)
            return
        check += 1    

main()

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

Solution (Python):
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7


x, n = multi_int_input()

arr = list_input()

arr = set(arr)

a = 0

while(True):
    l = x - a
    r = x + a

    if (l not in arr):
        print(l)
        break
    elif (r not in arr):
        print(r)
        break

    a+=1

Solution (Python):
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
p=list(map(int,input().split()))
for i in range(200):
    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()))
xp = x
xm = x
for i in range(n+1):
    if not xm in p:
        print(xm)
        exit()
    if not xp in p:
        print(xp)
        exit()
    xp += 1
    xm -= 1

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

for i in range(100):
    if not X + i in P:
        p = X + i
        break

for i in range(100):
    if not X - i in P:
        q = X - i
        break

if abs(X-p) == abs(X-q):
    print(q)
elif abs(X-p) > abs(X-q):
    print(q)
else:
    print(p)

Solution (Python):
nums = set(range(-200, 200))

X, N = map(int, input().split())
p = set(map(int, input().split()))
dist = 10**9
ans = 10**9

for k in sorted(nums - p):
    if abs(X - k) < dist:
        ans = k
        dist = abs(X - k)
print(ans)

Solution (Python):
def solve(X, P):
    if X not in P:
        return X
    l = X
    while l in P:
        l -= 1
    r = X
    while r in P:
        r += 1
    return min(l, r, key=lambda x: (abs(x - X), x))


def main():
    X, N = map(int, input().split())
    P = [int(p) for p in input().split()]
    print(solve(X, P))


if __name__ == "__main__":
    main()

Solution (Python):
inf = float('inf')


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

    ans = inf
    score = inf
    for i in range(-1, 102):
        tmp = abs(x - i)
        if score > tmp and i not in p:
            ans = i
            score = tmp
    print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):
from bisect import bisect_left as bl
ox, n = map(int, input().split())
if n == 0:
    print(ox)
    exit()
a = list(map(int, input().split()))
a.sort()
x = ox
i = bl(a, x)
while i < n and a[i] == x:
    i += 1
    x += 1
up = x
x = ox
i = bl(a, x)
while i >= 0 and a[i] == x:
    i -= 1
    x -= 1
down = x
if up-ox < ox-down:
    print(up)
else:
    print(down)

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

if N == 0:
  print(X)
else:
  P = sorted(list(map(int, input().split())))
  ans = X
  for i in range(101):
    if X - i not in P:
      ans = X - i
      break
    else:
      if X + i not in P:
        ans = X + i
        break
      
  print(ans)

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

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

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

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

Solution (Python):
x,n=map(int,input().split())
num=list(map(int,input().split()))
mini=1000
ans=x
for i in range(102,-1,-1):
    if i in num:
        continue
    if abs(x-i)<=mini:
        mini=abs(x-i)
        ans=i
print(ans)

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    
    
    

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

    sel_X = -1
    diff_X = float("inf")
    for x in range(-200, 200, 1):
        if x in P:
            continue
        if abs(x - X) < diff_X:
            sel_X = x
            diff_X = abs(x - X)
    print(sel_X)



if __name__ == '__main__':
    main()

Solution (Python):
x, n = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
else:
    p = list(map(int, input().split()))
list_ = [i for i in range(-1, max(p) + 2)]
res = -1
for i in list_:
    if i in p:
        pass
    else:
        if abs(i - x) < abs(res - x):
            res = i
print(res)

Solution (Python):
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
ns = list(map(int, input().split()))
ns = set(ns)
for i in range(n+1):
    if x - i not in ns:
        print(x - i)
        break
    elif x + i not in ns:
        print(x + i)
        break

Solution (Python):
X,N = map(int,input().split())
if(N != 0):
 P = list(map(int,input().split()))
 ans_l = []
 ans = float('inf')
 for j in range(102):
   if(j in P):
      continue
   else:
      if(abs(ans-X)>abs(j-X)):
        ans = j
else:
  ans = X     
  
print(ans)

Solution (Python):
X, N = map(int, input().split())
p = set(map(int, (input().split())))
i = 1
while True:
    j = ((i%2)*2-1) * (i//2)
    
    if X+j not in p:
        ans = X+j
        break
    i += 1
print(ans)

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

  for i in range(0,101):
    check=x-i
    if not check in p:
      print(check)
      break
    check=x+i
    if not check in p:
      print(check)
      break

if n==0:
  print(x)

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

dist_min = 1000000
ans = 10000
for i in range(-10, 110):
    if i in P:
        continue
    else:
        dist = abs(X-i)
        
        if dist_min>dist:
            dist_min = dist
            ans = i
print(ans)

Solution (Python):
X, N = map(int,input().split())
P = set(map(int,input().split()))
tmp = 101
for i in range(-100,110):
    if i in P:
        continue
    elif tmp > abs(X-i):
        tmp = abs(X-i)
        ans = i
print(ans)

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

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

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

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

ans1 = X
ans2 = X

while True:

    if not ans1 in P:
        print(ans1)
        exit()
    if not ans2 in P:
        print(ans2)
        exit()
    ans1 -= 1
    ans2 += 1

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

Solution (Python):
import math as mt


def ro(n):
  return mt.floor(mt.sqrt(n))
def ya():
  print("Yes")
  return
def na():
  print("No")
  return


x,n=map(int,input().split())
if n>0:
  lis=list(map(int,input().split()))
  lis.sort()


kai=1

while 1:
  if n==0:
    break
  if not x in lis:
    break
  x-=kai
  kai+=1
  if not x in lis:
    break
  x+=kai
  kai+=1
print(x)

Solution (Python):
import numpy as np

x, n = list(map(int, input().split()))
ps = list(map(int, input().split()))
cand = [i for i in range(-2, 110) if i not in ps]
abs_cand = [abs(x - c - 0.1) for c in cand]

print(cand[np.array(abs_cand).argmin()])

Solution (Python):

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

for i in range(100):

  if X-i in P:
    pass
  else:
    print(X-i)
    break

  if X+i in P:
    pass
  else:
    print(X+i)
    break

Solution (Python):
X,N = map(int,input().split())
if N==0:
  print(X)
else:
  p = list(map(int,input().split()))
  if X in p:
    p.remove(X)
    ans = 0
    for i in range(1,100):
      a = X+i
      b = X-i
      if b in p:
        p.remove(b)
      else:
        ans = b
        break

      if a in p:
        p.remove(a)
      else:
        ans = a
        break

    print(ans)
  else:
    print(X)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = x
for i in range(300):
    if ans in p:
        ans += (-1)**(i+1)*(i+1)
    else:
        print(ans)
        break

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

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

tmp = 1

if X not in PList or N == 0:
    print(X)

else:
    while 'true':
        if X - tmp not in PList:
            print(X - tmp)
            break
        elif X + tmp not in PList:
            print(X + tmp)
            break
        else:
            tmp += 1

Solution (Python):


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



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

ans = -1

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

print(ans)

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

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

Solution (Python):
X, N = map(int, input().split())
P = set(map(int, input().split()))
i = 0
while True:
    if (X-i) not in P:
        print(X-i)
        break
    if (X+i) not in P:
        print(X+i)
        break
    i += 1

Solution (Python):
X,N,*p = map(int, open(0).read().split())
ps = set(p)
if X not in ps:
    print(X)
else:
    for i in range(1,101):
        if X - i not in ps:
            print(X-i)
            break
        if X + i not in ps:
            print(X+i)
            break

Solution (Python):



def main():
    X, N = map(int, input().split())
    A = set(map(int, input().split()))

    for i in range(1000):
        if not X-i in A:
            print(X-i)
            break
        elif not X+i in A:
            print(X+i)
            break

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    x,n = map(int,input().split())
    p = set(list(map(int,input().split())))
    ans = 10000000000
    for i in range(-1000,1001):
        if i in p:
            continue
        else:
            d = abs(x-i)
            if d < ans:
               ans = d
               check = i 
    print(check)

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

ans = 0
mini = 1000
for i in range(-1000, 1000):
    if not i in p:
        if abs(X - i) < mini:
            mini = abs(X - i)
            ans = i
print(ans)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p = set(p)
i = 0
while True:
    ans1 = x+i
    ans2 = x-i
    if ans1 not in p and ans2 not in p:
        print(min(ans1,ans2))
        exit()
    elif ans1 not in p:
        print(ans1)
        exit()
    elif ans2 not in p:
        print(ans2)
        exit()
    else:
        i += 1
        continue

Solution (Python):
def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split())) if N else []

    ans = X

    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)

if __name__ == '__main__':
    main()

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


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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

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

num = 0
ans = 10 ** 9
for i in range(102):
	if num < len(p) and i == p[num]:
		num += 1
		continue
	if ans > abs(x-i):
		ans = abs(x-i)
		res = i

print(res)

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

def main():
    x, N = map(int, readline().split())

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

    P = set([int(i) for i in readline().split()])

    for i in range(60):
        if x - i not in P:
            print(x - i)
            break
        if x + i not in P:
            print(x + i)
            break



if __name__ == "__main__":
    main()

Solution (Python):
import sys

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



now = 0
while 1:
    if X - now not in P:
        print(X - now)
        sys.exit()
    elif X + now not in P:
        print(X + now)
        sys.exit()
    now += 1

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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 LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	x, n = LI()
	p = LI()
	i = 0
	while True:
		if x - i not in p:
			print(x-i)
			break
		elif x + i not in p:
			print(x+i)
			break
		i += 1



if __name__ == '__main__':
    main()

Solution (Python):

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


p_L = set(p_L)

sa = 101
for i in range(0,200):
    if i not in p_L:
        if sa > min(sa,abs(i-x)):
            sa = abs(x-i)
            ans = i
        

print(ans)

Solution (Python):
X,N = map(int,input().split())
a = []
if N != 0:
  a = list(map(int,input().split()))
if 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):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)


x, n = (int(x) for x in input().split())
if n == 0:
    print(x)
    exit()
P = list(int(x) for x in input().split())

for i in range(53):
    if x-i not in P:
        print(x-i)
        exit()
    if x+i not in P:
        print(x+i)
        exit()

Solution (Python):
import math


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

while True:

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

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

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

print(ans)

Solution (Python):
import sys
from math import pi, cos, sqrt
from collections import defaultdict
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    x, n = geta(int)
    p = set(tuple(geta(int)))

    if x not in p:
        print(x)
        return

    x1 = x - 1
    x2 = x + 1

    while True:
        if x1 not in p:
            print(x1)
            return

        if x2 not in p:
            print(x2)
            return

        x1 -= 1
        x2 += 1


if __name__ == "__main__":
    main()

Solution (Python):
import sys

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

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

d=0
for i in range(1000):
    if x-d not in p:
        print(x-d)
        sys.exit()
    elif x+d not in p:
        print(x+d)
        sys.exit()
    d+=1

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

s = list(range(0, 102))
for pi in p:
    s.remove(pi)

y = [(abs(pi - X), pi) for pi in s]
ans = min(y)[1]
print(ans)

Solution (Python):
def main():
    x,n = map(int,input().split())
    p = set(map(int,input().split()))
    x1,x2 = x,x
    if n == 0:
        print(x)
        return 0
    if x not in p:
        print(x)
        return 0
    while True:
        x1 -= 1
        x2 += 1
        if x1 not in p:
            print(x1)
            return 0
        if x2 not in p:
            print(x2)
            return 0

if __name__ == '__main__':
    main()

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
k=0
sa=100
for i in range(200,-200,-1):
    if i in p:
        continue
    value=abs(x-i)
    if value<=sa:
        k=i
        sa=value
print(k)

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

if N == 0:
  print(X)
else:
  ps = set(list(map(int, input().split())))

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

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

q = set(range(-1, 100 + 2)) - set(p)

f = []

for e in q:
  f.append((abs(e - x), e - x))

print(x + min(f)[1])

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
f = [False] * 301

    
a = 1145141919
ans = 0
for i in range(-100,300):
    fl = 1
    for j in p:
        if i == j:
            fl = 0
            
    if fl == 1:
        if abs(i-x) < a:
            ans = i
            a = abs(i-x)
            
print(ans)

Solution (Python):
X, N = map(int, input().split())
if N >= 1:
    P = sorted(list(map(int, input().split())))
else:
    P = []

c = 200
for x in range(-1, 102):
    if x in P:
        continue
    else:
        tmp = abs(X-x)
        if tmp < c:
            c = tmp
            ans = x
print(ans)

Solution (Python):
X, N =map(int, input().split())
p = list(map(int, input().split()))
for k in range(300):
    if X - k not in p:
        print(X-k)
        break
    if X + k not in p:
        print(X+k)
        break

Solution (Python):
import sys, math




from collections import defaultdict as dd, deque, Counter

def data(): return sys.stdin.buffer.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')

INF = float('inf')
mod = 998244353


x,n=mdata()
p=set(mdata())
m=x
v=0
for i in range(1,102):
    if i not in p:
        if abs(i-x)<m:
            v=i
            m=abs(i-x)
out(v)

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

ans = None
d = float('inf')
for i in range(-100, 200):
    if i in PS:
        continue
    a = abs(X-i)
    if a < d:
        ans = i
        d = a

print(ans)

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

Solution (Python):
import sys
X, N = map(int, sys.stdin.readline().rstrip().split())
P = list(map(int, sys.stdin.readline().rstrip().split()))
P = set(P)
for i in range(1000):
    if X - i not in P:
        print(X - i)
        exit()
    if X + i not in P:
        print(X + i)
        exit()

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

if n!=0:
  p_list = list(map(int, input().split()))

  res = set(range(102)) - set(p_list)
  res = [(abs(r-x), r) if r<=x else (abs(r-x)+0.5, r)
         for r in res]
  res = sorted(res, key=lambda r: r[0])

  print(res[0][1])
else:
  print(x)

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

mini = None
minabs = 1000

for i in range(102):
    if i not in Ps and abs(X-i) < minabs:
        mini = i
        minabs = abs(X-i)
print(mini)

Solution (Python):
import sys

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

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

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

for i in range(200):
    a=X-i
    b=X+i

    if a not in p_list:
        print(a)
        sys.exit(0)
    
    if b not in p_list:
        print(b)
        sys.exit(0)

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

for i in range(200):
    y,yy = X-i,X+i
    if y not in P:
        print(y)
        break
    elif yy not in  P:
        print(yy)
        break

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

for i in range(101):
    if not X - i in A:
        print(X - i)
        break
    if not X + i in A:
        print(X + i)
        break

Solution (Python):

import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def BinarySearch(num, List):
    if len(List) == 0:
        print("Erorr : list has no element")
        return
    left,right = 0,len(List)
    while left < right:
        mid  = (left+right)//2
        if num < List[mid]:
            right = mid
        else:
            left = mid + 1
    return right


def main():
    x,n = na()
    ps = sorted(na())
    if n==0:
        print(x)
        return
    cnt = 0
    while 1:
        right = BinarySearch(x-cnt, ps)
        if ps[right-1] != x-cnt:
            print(x-cnt)
            return
        right = BinarySearch(x+cnt, ps)
        if ps[right-1] != x+cnt:
            print(x+cnt)
            return
        cnt += 1
    return


if __name__ == '__main__':
    main()

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

p=[int(i) for i in input().split()]
p.sort()
p.append(999999)

sco=999999
ans=None
i=-2
now=0
while i<105:
    if abs(i-x)<sco and p[now]!=i:
        sco=abs(i-x)
        ans=i
    i+=1
    if i>p[now]:
        now+=1
print(ans)

Solution (Python):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

X,N=nm()
p=nl()
cur=0
while(1):
    min_X=X-cur
    max_X=X+cur
    if(min_X not in p):
        print(min_X)
        sys.exit(0)
    if(max_X not in p):
        print(max_X)
        sys.exit(0)
    cur+=1

Solution (Python):
X, N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
else:
  print(X)
  quit()
  
b = True
i = 0
while b:
  if X - i not in p:
    print(X - i)
    quit()
  elif X + i not in p:
    print(X + i)
    quit()
  i += 1

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

for i in range(X, 1000):
    if i not in P:
        a = i
        break
b = 0
for i in range(X, -1, -1):
    if i not in P:
        b = i
        break

if a-X < X-b:
    print(a)
else:
    print(b)

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

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

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = None
dif = 10**10

for i in range(-1000, 1000):
    if i in p:
        continue
    if abs(i - x) < dif:
        dif = abs(i - x)
        ans = i

print(ans)

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

p_set = set(p)

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

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

while(dif <= x):
    if x - dif not in p:
        print(x - dif)
        break
    if x + dif not in p:
        print(x + dif)
        break
    dif += 1

Solution (Python):
x, n = map(int, input().split())
array = [int(x) for x in input().split()]
res = float("inf")
diff = float("inf")
for a in range(200):
    if diff > abs(x-a) and a not in array:
        diff = abs(x-a)
        res = a
else:
    print(res)

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

while(True):
    x1=X-count
    x2=X+count
    if x1 not in p:
        print(x1)
        sys.exit()
    if x2 not in p:
        print(x2)
        sys.exit()    
    count+=1

Solution (Python):
X,N = map(int,input().split())
if N != 0:
    p = list(map(int,input().split()))
    setp = set(p)
    ans_plus = X
    ans_minus = X
    val = 0
    while True:
        ans_plus = X + val
        ans_minus = X - val
        if ans_minus not in setp:
            print(ans_minus)
            break
        elif ans_plus not in setp:
            print(ans_plus)
            break
        else:
            val += 1
else:
    print(X)

Solution (Python):
x,n = list(map(int, input().split()))
p = set(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())
p = list(map(int, input().split()))

ans = -1
i = 1

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

while ans == -1:
    temp = x -i
    if temp not in p:
        ans = temp
        break
    temp = x + i
    if temp not in p:
        ans = temp
        break
    i += 1

print(ans)

Solution (Python):
X,N = map(int,input().split())
if N==0:
    li = [-1]
else:
    li = list(map(int,input().split()))

mm = 200
for i in range(-10,110):
    for j in li:
        if i==j:
            break
    else:
        if abs(i-X)<abs(mm-X):
            mm = i
print(mm)

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

P = set(list(map(int, input().split())))

if X in P:
    ans = -1
else:
    ans = 0
for i in range(102):
    if i in P:
        continue
    if abs(i-X) < abs(ans-X):
        ans = i

print(ans)

Solution (Python):
from bisect import bisect_left as bil
from bisect import bisect_right as bir
x, N = map(int, input().split())
*A, = map(int, input().split())
S = set(A)

mn = 1 <<60
mna = -1
for i in range(-100, 200):
    if i in S:
        continue
    if abs(i - x) < mn:
        mn  = abs(i - x)
        mna = i

print(mna)

Solution (Python):
X,N = map(int, input().split())
p = list(map(int, input().split()))
ans = -100
for i in range(-10,110,1):
    if not (i in p):
        if abs(X-ans)>abs(X-i):
            ans = i

print(ans)