Problem:
 Score : 300 points    Problem Statement Given are an integer X and an integer sequence of length N : p_1, \ldots, p_N .  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X , that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.      Constraints  1 \leq X \leq 100  0 \leq N \leq 100  1 \leq p_i \leq 100  p_1, \ldots, p_N are all distinct.  All values in input are integers.         Input Input is given from Standard Input in the following format:  X  N  p_1  ...  p_N       Output Print the answer.        Sample Input 1 6 5
4 7 10 6 5      Sample Output 1 8  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the one nearest to 6 is 8 .       Sample Input 2 10 5
4 7 10 6 5      Sample Output 2 9  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the ones nearest to 10 are 9 and 11 . We should print the smaller one, 9 .       Sample Input 3 100 0      Sample Output 3 100  When N = 0 , the second line in the input will be empty. Also, as seen here, X itself can be the answer.

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

dl=[abs(x-i) for i in p]


for i in range(101):
    c=dl.count(i)

    if i==0:
        if c==1:
            continue
        else:
            print(x)
            exit()

    if c==0:
        print(x-i)
        exit()
    elif c>=2:
        continue
    else:
        b=dl.index(i)
        print(x-(p[b]-x))
        exit()

Solution (Python):
s = input().split()
intX = int(s[0])
intN = int(s[1])
inList = list(map(int,input().split()))

iCnt = 101
minDiv = 101
rCnt = -2
div = 0
while iCnt > -2 :
    if (inList.count(iCnt) == 0) : 
        div = abs(intX - iCnt)
        if (minDiv >= div) :   
            minDiv = div
            rCnt = iCnt
    iCnt -= 1
print(rCnt)

Solution (Python):
import os
import sys
from io import BytesIO, IOBase
import math
def inputIntArray():
    return list(map(int, input().rstrip().split()))


def inputArray():
    return input().rstrip().split()


def inputVars():
    return map(int, input().rstrip().split())


def inputNum():
    return int(input())


def main():
    x, n = inputVars()
    if n == 0:
        print(x)
        return
    arr = inputIntArray()
    minRes = x
    if x not in arr:
        print(x)
        return
    minRes = float('inf')
    
    for num in range(-1, 110):
        if num not in arr:
            minRes = num if abs(num - x) < abs(x - minRes) else minRes
    print(minRes)



BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

    target_abs = [0]*100

    for i in range(n):
        if abs(p[i]-x) >= 100:
            continue
        elif p[i]-x > 0:
            target_abs[abs(p[i]-x)] += 1
        else:
            target_abs[abs(p[i]-x)] += 2

    ans = 1000000
    for i in range(100):
        if i == 0:
            if target_abs[i] == 0:
                ans = x
        elif ans == 1000000:
            if target_abs[i] == 0:
                ans = x - i
            elif target_abs[i] == 1:
                ans = x - i
            elif target_abs[i] == 2:
                ans = x + i
    print(ans)

Solution (Python):
from sys import stdin, stdout
import sys
INF=1e9
import bisect
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)


x,n=get_ints()
p=get_array()
if n==0:
    print(x)
else:
    diff1=INF
    ans=0
    for i in range(-101,102):
        if i not in p:
            diff=abs(i-x)
            if diff<diff1:
                diff1=diff
                ans=i
    print(ans)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    a = x
    b = x
    while a in p:
        a -= 1
    while b in p:
        b += 1
    if abs(a -x) > abs(b - x):
        print(b)
    else:
        print(a)

Solution (Python):
import math

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


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

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]

if X < minimum or maximum < X:
    print(X)
    exit()

diff_min = abs(X - minimum - 1)
diff_max = abs(X - maximum + 1)
if diff_min == diff_max:
    answer = min(minimum - 1, maximum + 1)
else:
    answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)

Solution (Python):
import numpy as np
X, N = list(map(int, input().split()))
try:
	p = np.array(list(map(int, input().split())))
except EOFError:
    print(X)
    exit()
I = np.arange(0, 102)
indices = np.argsort(np.abs(I - X), kind='stable')
for idx in indices:
    if I[idx] not in p:
        print(I[idx])
        break

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
Pli = set(sorted(P))
X1 = X
X2 = X
while True:
    if X1 not in Pli:
        print(X1)
        break
    elif X2 not in Pli:
        print(X2)
        break
    else:
        X1 -= 1
        X2 += 1

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

if (int(n)>0):
  add = 1
  count = 3
  p = list(map(int,input().split()))

  if (int(x) not in p):
    print(int(x))
    count=1


  while (count==3):
    count = 0
    for i in range(int(n)):
      if (abs(int(p[i])-int(x)) == add):
        count = count+1
    if (count==2):
        add = add+1
        count=3
    if (count==1):
      if (int(x)-add in p):
        print(int(x)+add)
      else:
        print(int(x)-add)
    if (count==0):
      print(int(x)-add)
else:
  print(int(x))

Solution (Python):
def main():
    import copy

    num, quantity = map(int, input().split())
    nums = list(map(int, input().split()))
    nums.sort()
    
    if quantity == 0:
        print(num)
        return
    
    i = 0

    minus_num = copy.copy(num)
    plus_num = copy.copy(num)

    while i < len(nums):
        if num not in nums:
            print(num)
            return
        
        if minus_num not in nums:
            print(minus_num)
            return
        
        if plus_num not in nums:
            print(plus_num)
            return
        
        minus_num = minus_num - 1
        plus_num = plus_num + 1

main()

Solution (Python):
x, n = [int(i) for i in input().split()]
arr = [int(j) for j in input().split()]
if x not in arr:
	print(x)
else:
	xl = x
	xr = x
	count = 0
	while True:
		if count % 2 == 0:
			xl -= 1
			if xl not in arr:
				print(xl)
				break
		else:
			xr += 1
			if xr not in arr:
				print(xr)
				break
		count += 1

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    l = [k for k in range(102)]
    for p in input().split():
        p = int(p)
        l[p] = 1000
    l_d = [x-k for k in l]
    l_sorted = sorted(l_d,key= lambda x: (-x+0.1, x)[x > 0])
    print(x-l_sorted[0])

Solution (Python):
x, n = [int(i) for i in input().split()]
if n > 0:
  p = [int(i) for i in input().split()]
  x1 = x
  while True:
    if x1 not in p:
      a = x1
      break
    else:
      x1 -= 1
  x1 = x
  while True:
    if x1 not in p:
      b = x1
      break
    else:
      x1 += 1
  if abs(x-b) < abs(x-a):
    print(b)
  elif abs(x-a) < abs(x-b):
    print(a)
  else:
    print(a) if a<b else print(b)
else:
  print(x)

Solution (Python):

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

if p.count(x) == 0:
    print(x)
else:
    ans_large = x
    ans_small = x
    cycle = 1
    while ans_large == x and ans_small == x:
        
        if p.count(x - cycle) == 0:
            ans_small -= cycle
            break
        
        if p.count(x + cycle) == 0:
            ans_large += cycle
            ans_small = 101 
        cycle += 1
    print(min(ans_large, ans_small))

Solution (Python):
import numpy as np
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(-100,200))
for i in p:
    if i in lista:
        lista.remove(i)
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """
    
    idx = np.abs(np.asarray(list) - num).argmin()
    print(list[idx])
if N == 0:
    print(X)
else:
    getNearestValue(lista, X)

Solution (Python):
import sys

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

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

comp = 101
for i in range(102):
    x = abs(X - i)
    if comp > x and i not in p:
        comp = x
        result = i

print(result)

Solution (Python):
def main():
    X, N = map(int, input().split())
    pList = list(map(int, input().split()))

    minusX = X
    plusX = X

    while True:

        if(minusX not in pList):
            print(minusX)
            return

        if(plusX not in pList):
            print(plusX)
            return
        
        minusX = minusX - 1
        plusX = plusX + 1
        

if __name__ == "__main__":
    main()

Solution (Python):
X, N=map(int,input().split())
if N==0:
  print(X)
  exit()
  
else:
  P=sorted(map(int, input().split()))
  
if P.count(X)==0:
  print(X)
  exit()
  
for n in range(N+30):
  if P.count(X-n)==0:
    print(X-n)
    exit()
  elif P.count(X+n)==0:
    print(X+n)
    exit()

Solution (Python):
a = list(map(int,input().split()))
if a[1] == 0:
  print(a[0])
else:
  b = list(map(int,input().split()))
  min_num = a[0]
  min_p = a[0]
  m = 1
  ans = a[0]
  
  
  for i in set(b):
    if min_num >= abs(a[0]-i):
      min_p = i
      min_num = abs(a[0] - min_p)
  
      
  
      
  
      
  while True:
    if (min_p - m) not in set(b):
      ans = min_p - m
      break
    elif (min_p + m) not in set(b):
      ans = min_p + m
      break
    m += 1
  print(ans)

Solution (Python):
def search_prev(X, P):
    while X >= min(P):
        if not P.__contains__(X):
            return X
        else:
            X -= 1
    return X


def search_next(X, P):
    while X <= max(P):
        if not P.__contains__(X):
            return X
        else:
            X += 1
    return X


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

    if N == 0:
        print(X)
        return

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

    xp = search_prev(X, P)
    dxp = X - xp
    xn = search_next(X, P)
    dxn = xn - X

    if dxp <= dxn:
        print(xp)
    else:
        print(xn)


if __name__ == "__main__":
    main()

Solution (Python):
def nearest(x,ar):
  i=0;t=x
  while t in ar:
    t-=1
  v=t
  t=x
  while (t in ar):
    t+=1
  if x-v>t-x:return t
  else: return v
  

def main():
  x,n=map(int,input().split())
  if n==0:
    print(x)
  else:
    ar=list(map(int,input().split()))
    print(nearest(x,ar))
main()

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

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

s=[]
ans=0
for i in range(201):
    if x+i in p:
        ans+=1
    else:
        s.append(x+i)

t=[]
for j in range(201):
    if x-j in p:
        ans+=1
    else:
        t.append(x-j)

cnt=min(abs(min(s)-x),abs(max(t)-x))
if abs(min(s)-x)==abs(max(t)-x):
    print(x-cnt)
else:
    if cnt+x in p:
        print(abs(cnt-x))
    else:
        print(cnt+x)

Solution (Python):
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
  for i in range (N+1):
    if X-i in L and X+i in L:
      pass
    elif X-i not in L:
      s=X-i
      break
    elif X-i in L and X+i not in L:
      s=X+i
      break
else:
  s=X


print(s)

Solution (Python):
a = list(map(int,input().split()))
x = a[0]
if a[1] == 0 :
    print(x)
else :
    b = list(map(int,input().split()))
    retu = []
    for i in range(0,102) :
        retu.append(i)
    for i in b :
        if i in retu :
            retu.remove(i)
    k = 1000
    ans = 0
    for i in retu :
        y = abs(i - x)
        if y < k :
            k = y
            ans = i
    print(ans)

Solution (Python):
x, n = map(int, input().split())
import numpy as np
P  = list(map(int, input().split()))
if len(P)==0:
    print(x)
else:
    a = x
    b = x
    for i in range(len(P)+1):
        if a not in P:
            print(a)
            break
        if b not in P:
            print(b)
            break
        a -= 1
        b += 1

Solution (Python):
x,n=map(int,input().split())
l=list(map(int,input().split()))
def y(x,l):
    k=0
    while k>-1:
        if x-k not in l:
            return (x-k)

        elif x+k not in l:
            return (x+k)
        else:
            k+=1

print(y(x,l))

Solution (Python):
XN = input().split()
X = int(XN[0])
N = int(XN[1])
if N == 0:
    print(X)
else:
    p = input().split()
    A = [None]*N
    for i in range(N):
        A[i] = abs(int(p[i])-X)
    if 0 not in A:
        print(X)
    else:
        j = 1
        while A.count(j) == 2:
            j += 1
        if A.count(j) == 0:
            print(X-j)
        else:
            if str(X-j) in p:
                print(X+j)
            else:
                print(X-j)

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

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

    num = set(range(-102, 102))

    l = list(num.difference(p))
    l.sort()

    ans = 0
    absol = 110

    for i in l:
        a = abs(X - i)
        if a < absol:
            absol = a
            ans = i
        else:
            pass

    print(ans)

Solution (Python):
X, N = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
if len(lst) == 0:
    print(X)
    exit()
A = X
while A in lst:
    A -= 1
B = X
while B in lst:
    B += 1
if X-A > B-X:
    print(B)
else:
    print(A)

Solution (Python):
x, n = map(int, input().split())
try:
    in_li = set(map(int, input().split()))
    num_li = list({i for i in range(min(list(in_li))-1,max(list(in_li))+2)} - in_li)
except:
    in_li = set()
    num_li = []

num_li.sort()
res = 0

if n == 0:
    print(x)
elif x not in in_li:
    print(x)
else:
    for i in num_li:
        if abs(x-i) < abs(x-res):
            res = i
    print(res)

Solution (Python):

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


if n <= 0:
    print(x)
else:
    p = list(map(int,input().split()))
    p.sort()
    p2 = [x for x in range(-200,200)]

    p_p2_diff = set(p)^set(p2)
    p_p2_diff_list = list(p_p2_diff)

    min_list = []
    for i in p_p2_diff_list:
        val = abs(x - i)
        min_list.append(val)

    print(p_p2_diff_list[min_list.index(min(min_list))])

Solution (Python):
import sys
import numpy as np

X,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(X)
    sys,exit()
pp = list(map(lambda x: abs(x-X), p))
pp.sort()
for i in range(1,100):
    tmp=X-pp[0]-i
    if not tmp in p:
        print(tmp)
        sys.exit()
    tmpp=X-pp[0]+i
    if not tmpp in p:
        print(tmpp)
        sys.exit()

Solution (Python):
import math



def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

def AddV2(v,w):
    return [v[0]+w[0],v[1]+w[1]]

dir4 = [[1,0],[0,1],[-1,0],[0,-1]]


def clamp(x,y,z):
    return max(y,min(z,x))

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            

def Zaatsu(a):
    a.sort()
    now = a[0][0]
    od = 0
    for i in range(n):
        if(now==a[i][0]):
            a[i][0]=od
        else:
            now = a[i][0]
            od+=1
            a[i][0] = od
    
    a.sort(key = lambda x : x[1])
    return a

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  
factinv = [1, 1]  
inv = [0, 1]  

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

def rl(x):
    return range(len(x))










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

if(n>0):
    a = list(map(int, input().split()))
else:
    a=[]

val = [0 for i in range(102)]

for i in a:
    val[i]=1

if(val[x]==0):
    print(x)
    exit()
    
for i in range(1,101):
    if(val[x-i]==0):
        print(x-i)
        exit()
    if(val[x+i]==0):
        print(x+i)
        exit()

Solution (Python):
x, n = map(int, input().split())
if n > 0:
    P = list(map(int, input().split()))
else:
    P = []

ans, dist = 0, 1000
for i in range(-200, 200):
    if i not in P:
        if abs(i - x) < dist:
            dist = abs(i - x)
            ans = i
print(ans)

Solution (Python):
X,N = map(int,input().split())
p = list(map(int, input().split()))
num=list(range(-99,201))
for i in range(N):
    num.remove(p[i])
min_=210
for i in range(len(num)):
    s=abs(X-num[i])
    if s<min_:
        min_=s
        min_list=[num[i]]
    elif s==min_:
        min_list.append(num[i])
print(min(min_list))

Solution (Python):
import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
x,n=get_ints()
p=get_array()
ans1=x 
ans2=x
for j in range(x,-100,-1):
    if j not in p:
        ans1=j 
        break
for k in range(x,200):
    if k not in p:
        ans2=k 
        break
if ans2-x<x-ans1:
    print(ans2)
elif x-ans1<ans2-x:
    print(ans1)
else:
    print(ans1)

Solution (Python):
X, N = map(int, input().split())
if N==0:
  print(X)
  exit()
else:
  A = sorted(map(int, input().split()))

if A.count(X)==0:
  print(X)
  exit()

for k in range(N+10):
  if A.count(X-k)==0:
    print(X-k)
    exit()
  elif A.count(X+k)==0:
    print(X+k)
    exit()

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

t = 0
for i in range(N + 1):
    x = X - i
    y = X + i
    if x in p_list:
        t += 0
    else:
        print(x)
        break
    if y in p_list:
        t += 0
    else:
        print(y)
        break

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

alpha = x
if not p:
  print(x)
  exit()

for i in range(n+1):
  if alpha in p:
    alpha += (i+1)*(-1)**(i+1)
    continue
  else:
    print(alpha)
    exit()

Solution (Python):
import math
X,N=map(int,input().split())
p = list(map(int,input().split()))
abs_list=[0]*N
for i,a in enumerate(p):
    abs_list[i]=a-X
abs_new=sorted(abs_list, key = abs)
flag1=False
flag2=False
flag=False
if N==0:
    flag=True
    print(X)
for i,a in enumerate(abs_new):
    if i%2==1:
        flag1=False
        flag2=False
    if i==0 and a!=0:
        print(X)
        flag=True
        break
    elif (math.floor((i-1)/2)+1)==a:
        flag1=True
    elif (math.floor((i-1)/2)+1)==(-a):
        flag2=True
    if i%2==0 and i!=0:
        if flag2==False:
            print(X-(math.floor((i-1)/2)+1))
            flag=True
            break
        elif flag1==False:
            print(X+math.floor((i-1)/2)+1)
            flag=True
            break
if flag==False:
    if abs_new[-1]==0:
        print(X-1)
    elif abs_new[-1]<0:
        if flag1==True:
            print(X+(abs_new[-1]-1))
        else:
            print(X-abs_new[-1])
    else:
        if flag2==True:
            print(X-(abs_new[-1]+1))
        else:
            print(X-abs_new[-1])

Solution (Python):
print(sorted((lambda n,p:[[p.count(i),abs(n[0]-i),i] for i in range(-1,102)])(list(map(int,input().split())),list(map(int,input().split()))))[0][2])

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

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

p_int_set = set(p_int_list)

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

for i in range(1, 10000):
    if X - i not in p_int_set:
        print(X - i)
        exit()
    elif X + i not in p_int_set:
        print(X + i)
        exit()

Solution (Python):
X,N=map(int,input().split())
p_list=list(map(int,input().split()))
f_list=list(range(102))
for i in p_list:
    f_list.remove(i)
ans=f_list[0]
for i in f_list:
    if abs(X-ans)>abs(X-i):
        ans=i
print(ans)

Solution (Python):
X,N=map(int,input().split())
if(N==0):
  print(X)
  exit()
P= list(map(int,input().split()))
c=-100
ans=100000
for i in range(200):
  a=0
  for i in range(200):
    if (abs(X-c)>=abs(X-c-a)):
      if not (c+a in P):
        
        if (abs(X-ans) >=abs(X-c-a)):
          ans=c+a
          
          
    a+=1
  c+=1
if (ans>X):
  if not(X-ans+X in P):
    ans=X-ans+X
print(ans)

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

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





















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

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

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

P = input().split()
for i in range(len(P)):
    P[i] = int(P[i])

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


abs_num_p = X + 1
abs_num_n = X - 1
while True:

    if abs_num_p in P:
        flag_p = True
    else:
        flag_p = False

    if abs_num_n in P:
        flag_n = True
    else:
        flag_n = False
    if(  flag_p == True  and flag_n == True ):
        abs_num_p += 1
        abs_num_n -= 1
        continue;
    elif(flag_p == True  and flag_n == False):
        print(abs_num_n)
        break;
    elif(flag_p == False and flag_n == True ):
        print(abs_num_p)
        break;
    elif(flag_p == False and flag_n == False):
        print(abs_num_n)
        break;

    i += 1

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

p.sort()
s = 0
t = 0

for i in range(0,103-x):
    if x+i not in p:
        s = x+i
        break

for j in range(0,-100,-1):
    if x+j not in p:
        t = x+j
        break

if abs(x-s) < abs(x-t):
    print(s)
else:
    print(t)

Solution (Python):
x,n = map(int,input().split())
l = list(map(int,input().split()))
i=0
while True:
    k1 = x-i
    if not(k1 in l):
        print(k1)
        break
    k2 = x+i
    if not(k2 in l):
        print(k2)
        break
    i+=1

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

def p(i):
    return i+1
def m(i):
    return i-1

if not X in A:
    print(X)
else:
    pl=p(X)
    mi=m(X)
    for _ in range(100):
        if not mi in A:
            print(mi)
            break
        else:
            mi = m(mi)
        if not pl in A:
            print(pl)
            break
        else:
            pl = p(pl)

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











pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
if len(np) == 0:
  print(x)
  exit()
np.sort()


mx = x
res = np[0]
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

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

flag = [True] * 105
for p in P:
    flag[p] = False

ans = [float("inf"), 0]
for i in range(105):
    if not flag[i]: continue

    if ans[0] > abs(i - X):
        ans[0] = abs(i - X)
        ans[1] = i

print(ans[1])

Solution (Python):
print(sorted((lambda n,p:[[p.count(i),abs(n[0]-i),i] for i in range(-100,200)])(list(map(int,input().split())),list(map(int,input().split()))))[0][2])

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


q = list(range(x-n,x+n+1))


for i in range(len(p)):
    if p[i] in  q:
        q[q.index(p[i])] = 0




a = [0]*len(q)
for i in range(len(q)):
    a[i]  = abs(q[i] - x)


print(q[(a.index(min(a)))])

Solution (Python):
x, n = input().split(' ')
line = input()
if line == '':
    print(x)
    exit()

x = int(x)

alist = line.split(' ')
for i in range(int(n)):
    alist[i] = int(alist[i])
if not x in alist:
    print(x)
    exit()

blist = [i for i in range(0,102)]
bset = set(blist)
aset = set(alist)
cset = bset-aset
clist = list(cset)
clist.append(x)
clist.sort()

count = 0
for i,v in enumerate(clist):
    if v == x:
        count = i
if count == 0:
    print(clist[1])
elif count == len(clist)-1:
    print(clist[-2])
else:
    minx = x - clist[count-1]
    maxx = clist[count+1]-x
    if minx > maxx:
        print(clist[count+1])
    else:
        print(clist[count-1])

Solution (Python):
import sys
import numpy as np

X, N = (int(item) for item in sys.stdin.readline().split())
p = np.array([int(item) for item in sys.stdin.readline().split()], dtype=np.int8)


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

diff = [0 for _ in range(100)]
for item in p-X:
    diff[abs(item)] += 1
diff_ans = 0
while(True):
    if diff[diff_ans] < 2:
        ans_small = X - diff_ans
        if diff_ans > 0:
            if ans_small in p:
                print(X + diff_ans)
            elif diff_ans:
                print(ans_small)
            break
        elif X not in p:
            print(X)
            break
    diff_ans += 1

Solution (Python):
x,n=map(int,input().split())
lis=[i-1 for i in range(103)]
flag=True
if n==0:
  flag=False
  print(x)

if flag:
  p=list(map(int,input().split()))
  for i in p:
    lis.remove(i)
  
  for i in range(len(lis)):
    if lis[i]>x:
      index=i
      break
  if abs(x-lis[index])<abs(x-lis[index-1]):
    print(lis[index])
  else:
    print(lis[index-1])

Solution (Python):
X,N = map(int, input().split())
P = list(map(int, input().split()))
sortP = sorted(P)
if N==0:
    print(X)
elif sortP[0]>X:
    print(X)
elif sortP[N-1]<X:
    print(X)
else:
    for n in range(sortP[0]-2,sortP[N-1]+2):
        if n in sortP:
            continue
        if n ==X:
            print(X)
            break
        elif n>X:
            if X-a<=n-X:
                print(a)
                break
            else:
                print(n)
                break
        a = n

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

if len(p)==0:
    print(x)
    exit()

for i in range(100):
    a = x+i
    b = x-i
    if p.count(b)==0:
        print(b)
        exit()
    elif p.count(a)==0:
        print(a)
        exit()

Solution (Python):
x,n = map(int,input().split())
p = set(map(int,input().split()))
i = 0
while i <= x:
  if (x-i) in p and (x+i) in p:
    i+=1
  elif (x-i) in p:
    print(x+i)
    break
  elif (x+i) in p:
    print(x-i)
    break
  else :
    print(x-i)
    break

Solution (Python):
import numpy as np
x,n = map(int,input().split())
p = list(map(int,input().split()))
q = []
for i in range(-101,102):
    q.append(i)
for i in range(n):
    q.remove(p[i-1])

def getNearestValue(list, num):

    
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]


print(getNearestValue(q, x))

Solution (Python):
x,n=map(int,input().split())
if(n==0):
  print(x)
else:
    l=[]
    l1=[]
    li=list(map(int,input().split()))
    for i in range(n+1):
        if x-i not in li:
            l.append(x-i)
        if x+i not in li:
            l1.append(x+i)
    a=max(l)
    b=min(l1)
    if(abs(a-x)>abs(b-x)):
        print(b)
    else:
        print(a)

Solution (Python):
n,m = map(int, input().split())
b = 0
ue = sita = n
flag = 0

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

while b == 0:
    for i in l:
        if(ue == i):
            flag = 1
            break
            
    if(flag == 0):
        b = 1
        break
        
    flag = 0
    ue += 1
    
b = 0
flag = 0

while b == 0:
    for i in l:
        if(sita == i):
            flag = 1
            break
            
    if(flag == 0):
        b = 1
        break
        
    flag = 0
    sita -= 1
    



    
if(ue-n > n-sita or ue-n == n-sita):
    print(sita)
else:
    print(ue)