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,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'
    
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in range(base**n):s=[tb//(base**bt)%base for bt in range(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
 
YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase

read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
input=lambda: sys.stdin.readline().rstrip()

class Tree:
    def __init__(self,inp_size=None,ls=None,init=True,index=1):
        self.LCA_init_stat=False
        self.ETtable=[]
        if init:
            if ls==None:
                self.stdin(inp_size,index=index)
            else:
                self.size=len(ls)+1
                self.edges,_=GI(self.size,self.size-1,ls,index=index)
        return
 
    def stdin(self,inp_size=None,index=1):
        if inp_size==None:
            self.size=int(input())
        else:
            self.size=inp_size
        self.edges,_=GI(self.size,self.size-1,index=index)
        return
    
    def listin(self,ls,index=0):
        self.size=len(ls)+1
        self.edges,_=GI(self.size,self.size-1,ls,index=index)
        return
 
    def dfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def bfs(self,x,func=lambda pr,prv,nx,dist:prv+dist,root_v=0):
        q=deque([x])
        v=[None]*self.size
        v[x]=root_v
        while q:
            c=q.popleft()
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=func(c,v[c],nb,d)
        return v
 
    def parent(self,x):
        return self.dfs(0,func=lambda pr,prv,nx,dist:pr,root_v=-1)
 
    def topological_sort(self,x):  
        tps=[]
        q=deque([x])
        v=[None]*self.size
        v[x]=0
        while q:
            c=q.popleft()
            tps.append(c)
            for nb,d in self.edges[c]:
                if v[nb]==None:
                    q.append(nb)
                    v[nb]=0
        return tps
 
    def EulerTour(self,x):
        q=deque()
        q.append(x)
        self.depth=[None]*self.size
        self.depth[x]=0
        self.ETtable=[]
        self.ETdepth=[]
        self.ETin=[-1]*self.size
        self.ETout=[-1]*self.size
        cnt=0
        while q:
            c=q.pop()
            if c<0:
                ce=~c
            else:
                ce=c
                for nb,d in self.edges[ce]:
                    if self.depth[nb]==None:
                        q.append(~ce)
                        q.append(nb)
                        self.depth[nb]=self.depth[ce]+1
            self.ETtable.append(ce)
            self.ETdepth.append(self.depth[ce])
            if self.ETin[ce]==-1:
                self.ETin[ce]=cnt
            else:
                self.ETout[ce]=cnt
            cnt+=1
        return
    
    def LCA_init(self,root):
        self.EulerTour(root)
        self.st=SparseTable(self.ETdepth,init_func=min,init_idl=inf)
        
        self.LCA_init_stat=True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            self.LCA_init(root)
        xin,xout=self.ETin[x],self.ETout[x]
        yin,yout=self.ETin[y],self.ETout[y]
        a=min(xin,yin)
        b=max(xout,yout,xin,yin)
        id_of_min_dep_in_et=self.st.query_id(a,b+1)
        return self.ETtable[id_of_min_dep_in_et]
 
    def __str__(self):
        return  str(self.edges)
 
    def show(self):
        if all([all([d==1 for nd,d in edge]) for edge in self.edges]):
            print( [[nd for nd,d in edge] for edge in self.edges] )
        else:
            print(self)
 
class SparseTable: 
    def __init__(self,ls,init_func=min,init_idl=float('inf')):
        self.func=init_func
        self.idl=init_idl
        self.size=len(ls)
        self.N0=self.size.bit_length()
        self.table=[ls[:]]
        self.index=[list(range(self.size))]
        self.lg=[0]*(self.size+1)
        
        for i in range(2,self.size+1):
            self.lg[i]=self.lg[i>>1]+1
 
        for i in range(self.N0):
            tmp=[self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) for j in range(self.size)]
            tmp_id=[self.index[i][j] if self.table[i][j]==self.func(self.table[i][j],self.table[i][min(j+(1<<i),self.size-1)]) else self.index[i][min(j+(1<<i),self.size-1)] for j in range(self.size)]
            self.table+=[tmp]
            self.index+=[tmp_id]
    
    
    def query(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        return self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))])
    
    
    def query_id(self,l,r):
        if r>self.size:r=self.size
        
        N=self.lg[r-l]
        a,b=self.index[N][l],self.index[N][max(0,r-(1<<N))]
        if self.table[0][a]==self.func(self.table[N][l],self.table[N][max(0,r-(1<<N))]):
            b=a
        return b
    
    
    def right_bound(self,pos,x):
        k=(self.size-pos).bit_length()
        for j in range(k)[::-1]:
            nx=pos+(1<<j)
            if nx<n and self.query(pos,nx+1)<=x:
                pos+=(1<<j)
        return pos
    
    
    def left_bound(self,pos,x):
        k=pos.bit_length()
        for j in range(k)[::-1]:
            nx=pos-(1<<j)
            if 0<=nx and self.query(nx,pos+1)<=x:
                pos-=(1<<j)
        return pos
 
    def __str__(self):
        return str(self.table[0])
 
    def print(self):
        for i in self.table:
            print(*i)
 
show_flg=False
show_flg=True
ans=0

x,n=LI()
p=LI()
for i in rep(200):
    if x-i not in p:
        print(x-i)
        exit()
    if x+i not in p:
        print(x+i)
        exit()

Solution (Python):

import sys


def solve(X: int, N: int, p: "List[int]"):
    sp = set(p)
    ans = min((i for i in range(-1, 107) if i not in sp), key=lambda x:abs(x-X))
    print(ans)
    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())
p=[int(x) for x in input().split()]
for i in range(102):
	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())
U=list(range(-1,102))
for i in [int(x) for x in input().split()]:
  del U[U.index(i)]

m=10**3
for i in U:
  if abs(i-X)<m or (abs(i-X)==m and i<d):
    m,d=abs(i-X),i
print(d)

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

Solution (Python):
X,N = map(int,input().split(" "))
target = X
if N != 0:
    p_list = list(map(int,input().split(" ")))

    target_num_min = X
    target_num_plus = X
    if X in p_list:
        while True:
            target_num_min -= 1
            if target_num_min not in p_list:
                target = target_num_min
                break
            target_num_plus += 1
            if target_num_plus not in p_list:
                target = target_num_plus
                break
print(target)

Solution (Python):
def main():
  x,n = [int(i) for i in input().split()]
  table = list(map(int, input().split()))
  
  for i in range(101):
    if x - i not in table:
      print(x-i)
      exit()
    elif x + i not in table:
      print(x+i)
      exit()
    	
if __name__ == "__main__":
  main()

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

if n!=0:
    a = list(map(int, input().split()))
else:
    a = []
    
h = {}

for i in range(n):
    h[a[i]] = True

i, left, right = x, x, x

while i<=101:
    if not h.get(i, False):
        left = i
        break
    i += 1

i = x

while i>=0:
    if not h.get(i, False):
        right = i
        break
    i -= 1

if abs(x-left) < abs(x-right):
    print(left)
elif abs(x-left) > abs(x-right):
    print(right)
else:
    print(min(left, right))

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
reps = [i for i in range(-1, 102)]
for elem in p:
    reps.remove(elem)
diff = 10 ** 7
ans = -100
for elem in reps[::-1]:
    rep = abs(x - elem)
    if rep <= diff:
        diff = rep
        ans = elem
print(ans)

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

i = n
c = 0
while c <= 100:
    i = n - c
    if not i in p:
        break

    i = n + c
    if not i in p:
        break

    c += 1
    
print(i)

Solution (Python):
x, n = map(int, input().split())
P = list(map(int, input().split()))
flag = [True] * 102  
for p in P:
    flag[p] = False
if flag[x]:
    ans = x
else:
    ans = -1
    d = 1
    while True:
        for idx in [x-d, x+d]:
            if flag[idx]:
                ans = idx
                break
        if ans != -1:
            break
        d += 1
print(ans)

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

notP = list(range(-10, 110))
for p in P:
    notP.remove(p)
ans = min(notP, key=lambda y: abs(x - y))
print(ans)

Solution (Python):
x,n = map(int, input().split())
if n == 0:
  print(x)
else:
  line = list(map(int, input().split()))
  sign = [0 for i in range(100)] 
  abs_list = [0 for i in range(100)] 

  for i in range(n):
    y = x - line[i]
    if y < 0:
      sign[abs(y)] += 1
    abs_list[abs(y)] += 1
  for mini in range(100):
    if mini == 0:
      if abs_list[mini] == 0:
        print(x)
        break
    else:
      if abs_list[mini] == 0:
        print(x - mini)
        break
      if abs_list[mini] == 1:
        if sign[mini] == 0:
          print(x + mini)
          break
        else:
          print(x - mini)
          break

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



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

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

notP = list(range(-10, 110))
for p in P:
    notP.remove(p)
ans = min(notP, key=lambda y: abs(x - y))
print(ans)

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

Solution (Python):
x,n=map(int,input().split())
l=[int(i) for i in input().split()]
bestval=100000
besti=0
for i in range(200):
  if i in l:
    continue
  if abs(x-i)<bestval:
    bestval=abs(x-i)
    besti=i
print(besti)

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

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

Solution (Python):
x,n=map(int,input().split())
sett=list(map(int,input().split()))
arr=[i for i in range(-1,102) if i not in sett]
min_=100000
ans=0
for i in arr:
    if abs(x-i)<min_:
        min_=abs(x-i)
        ans=i
print(ans)

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

lst = [0]*102

for i in p:
    lst[i] = 1
    
if lst[x] == 0:
    print(x)
elif lst[x] == 1:
    for i in range(1, 102):
        if lst[x-i] == 0:
            print(x-i)
            exit()
        elif lst[x+i] == 0:
            print(x+i)
            exit()

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

result = []

for i in range(102):
    result.append(i)

ans = set(result)-p
ans1 = 1*10**50


for count, i in enumerate(ans):
    if (ans1 > abs(i-X)):
        ans1 = abs(i-X)
        index = count

print(list(ans)[index])

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

sett=list(map(int,input().split()))
arr=[i for i in range(-1,102) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)

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

sett=list(map(int,input().split()))
arr=[i for i in range(-5,151) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)

Solution (Python):
x, n = map(int, input().split())
P = set(map(int, input().split()))
if n==0:
    print(x)
elif n==100 and x<=50:
    print(0)
elif n==100 and 50<x:
    print(101)
else:
    T = set(list(range(-1, 102))) - P
    diff = 101
    for t in T:
        if diff > abs(x-t):
            diff = abs(x-t)
            ans = t
    print(ans)

Solution (Python):
import sys
import numpy as np

input = sys.stdin.readline

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

abs_v = np.inf
res = 0
s = {i for i in range(102)}
for x in (s-p):
    if abs_v > abs(X-x):
        abs_v = abs(X-x)
        res = x

print(res)

Solution (Python):
x,n=(int(i) for i in input().split())
if(n==0):
  print(x)
else:
  l=sorted([int(i) for i in input().split()])
  if(x not in l):
    print(x)
  else:
    k=l.index(x)
    c1,c2=0,0
    for i in range(k-1,-1,-1):
      if(x-l[i]>k-i):
        c1=l[i+1]-1
        break
    if(c1==0):
      c1=l[0]-1
    for i in range(k+1,n):
      if(l[i]-x>i-k):
        c2=l[i-1]+1
        break
    if(c2==0):
      c2=l[n-1]+1
    if(x-c1>c2-x):
      print(c2)
    else:
      print(c1)

Solution (Python):
a,b=input().split()
pp=input().split()
a=int(a)
b=int(b)
p=[]
for pa in pp:
    p.append(int(pa))
x=0
y=-1
while True:
    if a+x not in p:
        aa=a+x
        break
    elif a+y not in p:
        aa=a+y
        break
    x+=1
    y+=-1
print(aa)

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

p = set(map(int, input().split()))
n = set(range(102))
l = n - p
ans = 10000
a = 10000
for i in l:
  tmp = abs(X - i)
  if a > tmp:
    a = tmp
    ans = i
  elif a == tmp:
    ans = min(ans, i)
    
print(ans)

Solution (Python):
X, N = (int(i) for i in input().split())  
p = list(int(i) for i in input().split())  
cnt = 1000
res = 0
for i in range(110):
  if i in p :
    cnt = cnt
  else:
    if abs(X-i) < cnt :
      cnt = abs(X-i)
      res  = i
print(res)

Solution (Python):




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

    P = list(map(int, input().split()))
    i = 0

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


if __name__ == "__main__":
    main()

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

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

  s = 0
  v = x 
  w = x

  while v in lst and w in lst:
    s += 1
    v = x - s
    w = x + s
  
  
  if v not in lst:
    print(v)
  else:
    print(w)

Solution (Python):
import sys
x,n = map(int,input().split())
    
p,f = x-1,x+1
bans = set(map(int,input().split()))

if n == 0 or x not in bans:
    print(x)
    sys.exit()

while True:
    if p not in bans:
        print(p)
        break 
    p -= 1
    
    if f not in bans:
        print(f)
        break 
    f += 1

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

X,N = map(int,readline().split())
P = set(list(map(int,readline().split())))
lo = X
hi = X
while True:
  if lo not in P:
    print(lo)
    break
  lo -= 1
  if hi not in P:
    print(hi)
    break
  hi += 1

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
s = 101
ans = 101
for i in range(-100,100+2):
    if not i in p:
        if s > abs(x-i):
            s = abs(x-i)
            ans = i
print(ans)

Solution (Python):
import sys
from math import floor,ceil,sqrt






















Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
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 ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

x,n = Ri()
a = Ri()

s =  set([i for i in range(0,102)])
for i in a:
    if i in s:
        s.remove(i)

val = -1
dif = INF
for i in s:
    if abs(x - i) < dif:
        dif = abs(x-i)
        val = i
print(val)

Solution (Python):
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ans=0
d=float('inf')
for i in range(102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

Solution (Python):
import sys
INF = 1 << 60
MOD = 10**9 + 7 
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    x, n = map(int, input().split())
    P = set(map(int, input().split()))
    diff = 0
    while 1:
        if not x - diff in P:
            print(x - diff)
            return
        if not x + diff in P:
            print(x + diff)
            return
        diff += 1
resolve()

Solution (Python):
X, N = list(map(int, input().strip().split()))
l = list(map(int, input().strip().split()))
l = sorted(l, reverse = False)
 
rslt = 200
 

if N == 0: rslt = X
if N != 0:
  if l[0] > X: rslt = X
  elif l[-1] < X: rslt = X
  elif (l[0]<=X) and (l[-1]>=X):
    e_min = int(l[0]-1)
    e_max = int(l[-1]+1)
    e_l = [i for i in range(e_min, e_max+1) if i not in l]
    for n in e_l[::-1]:
      if abs(X-n) <= abs(X - rslt): rslt = n
  
print(rslt)

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

p = set(p)
ans = -5
d = 1000
for i in range(-5, 105):
    if i not in p:
        if d > abs(x-i):
            ans = i
            d = abs(x-i)

print(ans)

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

Solution (Python):

x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
res=0
for i in range(102):
 if i not in p:
  if abs(x-res)>abs(x-i):
   res=i
print(res)

Solution (Python):
x, n = map(int, input().split())
p = {int(i) for i in input().split()}
 
for i in range(55):
    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 input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    P.sort()
    answer = INF
    diff = INF
    for i in range(-100, 200):
        if i in P:
            continue
        if abs(X - i) < diff:
            answer = i
            diff = abs(X - i)
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
     x,n = map(int,input().split())
     L = list(map(int,input().split()))
     i = 0
     if n == 0 or x not in L:
          print(x)
          return 0
     while(True):
          i += 1
          if x - i not in L:
               print(x - i)
               return 0
          if x + i not in L:
               print(x + i)
               return 0
main()

Solution (Python):
import bisect

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

    idx = bisect.bisect_left(p, X)
    
    if p[idx] != X:
        print(X)
    else:
        pre = idx - 1
        nxt = idx + 1
        pre_num = X - 1
        for i in range(pre, -1, -1):
            if p[i] != pre_num:
                break
            else:
                pre_num -= 1
        nxt_num = X + 1
        for i in range(nxt, N):
            if p[i] != nxt_num:
                break
            else:
                nxt_num += 1
        if abs(X - pre_num) <= abs(X - nxt_num):
            print(pre_num)
        else:
            print(nxt_num)

Solution (Python):
def main():
     x,n = map(int,input().split())
     L = list(map(int,input().split()))
     i = 0
     if n == 0 or x not in L:
          print(x)
          return 0
     while(True):
          i += 1
          if x - i not in L:
               print(x - i)
               return 0
          if x + i not in L:
               print(x + i)
               return 0
main()

Solution (Python):
import sys
from bisect import bisect_left
x, n = [int(i) for i in sys.stdin.readline().split()]
p_s = [int(i) for i in sys.stdin.readline().split()]
candidate = [i for i in range(-1000,1000) if i not in p_s]
ind = bisect_left(candidate, x)
if ind == len(candidate):
    print(candidate[-1])
elif x - candidate[ind-1] <= candidate[ind] - x:
    print(candidate[ind-1])
else:
    print(candidate[ind])

Solution (Python):
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
	print(x)
	exit(0)
if x in p:
	a,b = 0,0
	for i in range(1,102):
		if x - i in p:
			continue
		else:
			a = x - i
			break
	for j in range(1,102):
		if x + j in p:
			continue
		else:
			b = x + j
			break
	if a < 0:
		print(b)
	elif b > 101:
		print(a)
	elif abs(x-a) <= abs(x-b):
		print(a)
	else:
		print(b)
else:
	print(x)

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()
  
i = 1
while True:
  if x-i not in P:
    print(x-i)
    exit()
  elif x+i not in P:
    print(x+i)
    exit()
  else:
    i += 1

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * 102
k = 999

for i in range(0, 101):
  for j in range(N):
    if p[j] == i:
      l[i] = 1
    j = j+1
  i = i+1
for i in range(-1, 101):
  i = i+1
  if l[i] == 1:
    continue
  k = min(k, abs(X-i))

if l[X-k] == 1:
    print(X+k)
else:
    print(X-k)

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

ans = -1
i = 0

while True:
    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())
p = list(map(int, input().split()))

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

ans = -1
i = 1

while True:
    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())
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):
x, n = map(int, input().split())
P = list(map(int, input().split()))

koho = [i for i in range(-100, 200) if i not in P]

koho.sort(key=lambda a: (abs(a - x), a))

print(koho[0])

Solution (Python):
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit(0)
inp = list(map(int,input().split()))
a = []
for i in range(-100,113):
  if i not in inp:
    a.append(i)

res = 0
minn = 1e5
for i in a:
  if abs(i-x) < minn:
    minn = abs(i-x)
    res = i
    
print(res)

Solution (Python):
import numpy as np

def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default

lis=[]
for i in range(102):
    lis.append(i)


listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;

 
X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]
 
    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max+1]
    arr=arr[arr>=P_min-1]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    
    lis_min=min(lis_)
 
    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

Solution (Python):
x,n=map(int,input().split())
p=sorted(list(map(int,input().split())))
q=[0]*(102)
for i in range(n):
    q[p[i]]=1
ans=(1000000,-1)
for i in range(102):
    if q[i]==0:
        if ans[0]>abs(i-x):
            ans=(abs(i-x),i)
print(ans[1])

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve():
    x, n = LI()
    p = LI()
    ans = 0
    for i in range(102):
        if not i in p:
            if abs(ans - x) > abs(x - i):
                ans = i
    print(ans)
    return



if __name__ == '__main__':
    solve()

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X, N, *P = map(int, read().split())
se = frozenset(P)

def gen_nums(X):
  low, high = X-1, X
  while True:
    yield high
    yield low
    low, high = low-1, high+1

for x in gen_nums(X):
  if x not in se:
    break

print(x)

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

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

p.sort()

ans = 1000000

memo = x

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

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


for i in range(100):
    ans = X - i
    if ans not in LP:
        print(ans)
        exit()
    else:
        dans = X + i
        if dans not in LP:
            print(dans)
            exit()

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):
x, n =map(int, input().split())
p = []
if n != 0:
    p = list(map(int, input().split()))

result = x
if n != 0:
    for i in range(0, 1000):
        if not (x - i) in p:
            print(x - i)
            break
        if not (x + i) in p:
            print(x + i)
            break
else:
    print(x)

Solution (Python):
X,N=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
nai=[]

for i in range(0,102):
  if i not in p:
    nai.append(i)
nai.append(X)
nai.sort()
ind=nai.index(X)
if abs(nai[ind-1]-X)<=abs(nai[ind+1]-X):
  print(nai[ind-1])
else:
  print(nai[ind+1])