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

Solution (Python):
import sys
import numpy as np


MODE = 1


DIMENSION = 2


INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

if len(s) == 1:
    print(s[0][0])
    exit()

X, N = s[0]
P = s[1]

x_upper = X
x_lower = X
while 1:
    if P.count(x_lower) == 0:
        print(x_lower)
        exit()
    elif P.count(x_upper) == 0:
        print(x_upper)
        exit()
    x_upper += 1
    x_lower -= 1

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    ls = [1, 2, 3, 5]
    X, N = input_number_list()
    P = input_number_list()
    if P.count(X) == 0:
        print(X)
        return
    d = 1
    while True:
        if P.count(X - d) == 0:
            print(X - d)
            break
        elif P.count(X + d) == 0:
            print(X + d)
            break
        d += 1


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
x, n = [int(i) for i in input().split()]
if n != 0:
  ps = np.array([int(i) for i in input().split()])

  ps.sort()

  m = -1000
  ans = m
  di = 0
  while ans == m:
    if not x - di in ps:
      ans = x - di
    elif not x + di in ps:
      ans = x + di
    di += 1
else:
  ans = x
print(ans)

Solution (Python):
date=input().rstrip().split(" ")
X=int(date[0])
N=int(date[1])
if N==0:
    print(X)
else:
    date0=list(map(int, input().split(" ")))
    date0=sorted(date0)
    if date0.count(X)==0:
        print(X)
    else:
        for i in range(1,51):
            C=date0.count(X-i)
            D=date0.count(X+i)
            if C==0:
                print(X-i)
                break
            elif D==0:
                print(X+i)
                break

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

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

ans = math.inf
off = 0
while ans == math.inf:

    left = x - off
    right = x + off

    try:
        p.index(left)
    except:
        print(left)
        exit()

    try:
        p.index(right)
    except:
        print(right)
        exit()
    off+=1

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

if(x not in t):print(x);exit()
down = x-1
up = x+1
while(True):
    if down not in t:print(down);exit()
    if up   not in t:print(up);exit()
    down-=1
    up+=1

Solution (Python):
X, N = map(int, input().split())
P = set(map(int, input().split())) if N > 0 else set()
for i in range(101):
    if X-i not in P:
        print(X-i)
        exit()
    if X+i not in P:
        print(X+i)
        exit()

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

ans = x
for i in range(2*n):
    if x-i not in nums:
        ans = x-i
        break
    elif x+i not in nums:
        ans = x+i
        break
    else:
        continue
print(ans)

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

    if not (X in set(p)):
        print(X)
        return

    bucket = [False] * 102
    for i in range(N):
        bucket[p[i]] = True
    
    high = 0
    low = 0
    for i in range(X,102):
        if not bucket[i]:
            high = i
            break

    for i in range(X,0,-1):
        if not bucket[i]:
            low = i
            break

    if abs(X-high) > abs(X-low):
        print(low)
    elif abs(X-high) == abs(X-low):
        print(min(low,high))
    else:
        print(high)
if __name__ == '__main__':
    solve()

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

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

v = 0
if N == 0:
    print(X)
else:
    while True:
        res = X - v
        if not res in p:
            break
        res = X + v
        if not res in p:
            break
        v += 1
    print(res)

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

Solution (Python):
x, n = map(int,input().split())
P = list(map(int,input().split()))
Q = []
ans = 100
for i in range(-100,101):
    if i+1 in P:continue
    else:
        Q.append(i+1)
for j in Q:
    d = abs(j - x)
    ans = min(d, ans)

l = x -ans
m = x + ans
if l in Q:
    print(l)
else:
    print(m)

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

num1 = X-1
num2 = X+1
if X not in p:
  print(X)
  sys.exit()
while 1:
  if num1 == 0:
    print(num1)
    break
  if num1 in p and num2 not in p:
    print(num2)
    break
    
  elif num1 not in p and num2 in p:
    print(num1)
    break
  elif num1 not in p and num2 not in p:
    print(num1)
    break
  else:
    num1 -= 1
    num2 += 1

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

  if N == 0:
    return print(X)

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

  P2 = set([abs(p-X) for p in P])
  
  for i in range(101):
    ans1 = X - i
    ans2 = X + i
    
    if ans1 not in P:
      print(ans1)
      return
    if ans2 not in P:
      print(ans2)
      return
  
main()

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

for i in range(100):
    m = X-i
    n = X+i
    if m not in nums: 
        print(m)
        break
    elif n not in nums: 
        print(n)
        break

Solution (Python):
x,n=map(int, input().split())
P=list(map(int, input().split()))
ans=[]
for i in range(102):
    ans.append(i)

m=99999999999999
for p in P:
    del ans[ans.index(p)]
y=99999999999999

for i in ans:
    if abs(i-x)<y:
        y=abs(i-x)
        m=i

print(m)

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

Solution (Python):


INF = 10 ** 10


def solve(x, n, ps):
    qs = sorted(set(range(0, 103)) - set(ps))
    delta = INF
    val = INF
    for q in qs:
        new_delta = abs(q - x)
        if new_delta < delta:
            delta = new_delta
            val = q
    return val


def main():
    x, n = (int(z) for z in input().split())
    ps = [int(p) for p in input().split()]
    res = solve(x, n, ps)
    print(res)



if __name__ == '__main__':
    main()

Solution (Python):
x, n = map(int,input().split())
p_list = list(map(int,input().split()))
p_list.sort()
ans_sa = abs(-1-x)
ans = -1
for i in range(0,200):
    if i in p_list:
        pass
    else:
        if ans_sa > abs(i-x):
            ans_sa = abs(i-x)
            ans = i
        elif ans_sa == abs(i-x):
            ans = min(ans,i)

print(ans)

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

Solution (Python):
targ, length = map(int, input().split(' '))

banned = [False] * 100

bans = input()
if bans != '':
    for ban in bans.split(' '):
        banned[int(ban) - 1] = True

for dist in range(100):
    if targ - dist > 0:
        if not banned[targ - dist - 1]:
            print(targ - dist)
            exit()
    else:
        print(targ - dist)
        exit()
    if targ + dist <= 100:
        if not banned[targ + dist - 1]:
            print(targ + dist)
            exit()
    else:
        print(targ + dist)
        exit()

Solution (Python):
import itertools
from collections import deque,Counter
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

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()
for i in range(1,5555555):
  a = x-i
  b = x+i
  if a not in p and b not in p:
    print(a)
    exit()
  if a not in p and b  in p:
    print(x-i)
    exit()
  if b not in p and a in p:
    print(x+i)
    exit()

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

ans=[float("inf"),float("inf")]
for i in range(102):
    if i in P:
        continue
    tmp=abs(i-X)
    if tmp<ans[0]:
        ans[0]=tmp
        ans[1]=i
print(ans[1])

Solution (Python):

import sys
import math
import itertools
import collections

def solve(X,N,P):
    ans = {i for i in range(-200,201,1)}
    ans -= set(P)
    result = 10**2
    q = []
    for a in list(ans):
        target = abs(X - a)
        if(result == target):
            q.append(a)
        elif(result > target):
            result = target
            q = [a]
    return min(q)
def main():
    X,N = map(int,input().split())
    P = list(map(int,input().split()))
    
    print(solve(X,N,P))

if __name__ == "__main__":
    main()

Solution (Python):
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x,n = IL()
    p = LI()
    i=0
    while True:
        if i==0:
            if not x in p:
                print(x)
                exit()
        else:
            if not x-i in p:
                print(x-i)
                exit()
            if not x+i in p:
                print(x+i)
                exit()
        i+=1
    return

if __name__=='__main__':
    main()

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

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

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 = map(int,input().split())
if n == 0:
    print(x)
    exit()
l = set(list(map(int,input().split())))
for i in range(max(x,100-x)+1):
    if x-i not in l:
        print(x-i)
        exit()
    if x+i not in l:
        print(x+i)
        exit()

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

n = 0
while True:
    candidate = X - n
    if candidate not in l:
        print(candidate)
        break
    candidate = X + n
    if candidate not in l:
        print(candidate)
        break
    n += 1

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
ans=0
num=0
while ans==0:
    if (x+num) not in p:
        ans=x+num
    if (x-num) not in p:
        ans=x-num
        if ans==0:
            break
    num+=1
print(ans)

Solution (Python):
xn = list(map(int, input().split()))
pn = list(map(int, input().split()))

for i in range(100):
    if(not ((xn[0] - i) in pn)):
        print(xn[0] - i)
        break
    if(not ((xn[0] + i) in pn)):
        print(xn[0] + i)
        break

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

Solution (Python):





















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

tmp = 1000
ans = 1000
for p in range(-120,121):
    if p in lisP:
        continue
    num = abs(X-p)
    if num == tmp:
        ans = min(ans,p)
    elif num < tmp:
        tmp = num
        ans = p

print(ans)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int,input().split()))
minimum = [-1,float('inf')]
item = [0]*102
for pi in p:
    item[pi] = 1
for i in range(102):
    if item[i] == 0 and minimum[1] > abs(x-i):
        minimum[1] = abs(x-i)
        minimum[0] = i
print(minimum[0])

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

arr = [i for i in range(max(P)+2) if i not in P]
diff = [abs(i - X) for i in arr]

print(arr[diff.index(min(diff))])

Solution (Python):
import numpy as np
import functools
import operator
import sys

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

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

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

L = [x for x in range(max(ps) + 3)]

for p in ps:
    L.remove(p)



min_absval = 100000000
val = 100000
for i, l in enumerate(L):
    absval = abs(l - X)

    if min_absval > absval:
        min_absval = absval
        val = l


print(val)

Solution (Python):
def main():
    X, N = map(int, input().split())
    if N != 0:
        A = list(map(int, input().split()))
    else:
        A = []
    min_diff = 1e5
    for i in range(0, 102):
        if i not in A:
            min_diff = min(min_diff, abs(i - X))
    
    for i in range(0, 102):
        if i not in A and abs(i - X) == min_diff:
            print(i)
            return 
  
if __name__ == '__main__':
    main()

Solution (Python):
X,N=map(int,input().split())
if N==0:
  print(X)
if N!=0:
  P=list(map(int,input().split()))
  list=[i for i in range(102)]


  for i in P:
    list[i]=-1

  sa=10**3
  ans=-1
  for i in range(len(list)):
    if abs(X-list[i])<sa:
      sa=X-list[i]
      ans=list[i]
  print(ans)

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
lst = list(map(int, input().split()))
dis = 10000
ans = 0
for i in range(300):
  if not i in lst:
    if abs(x-i) < dis:
      dis = 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()))

exist = [False] * 102
for pi in p:
  exist[pi] = True
  
minabs = X
ans = 0
for i in range(102):
  if exist[i]:
    continue
  if abs(X-i) < minabs:
    ans = i
    minabs = abs(X-i)
    
print(ans)

Solution (Python):
X,N = map(int,input().split())
if N != 0:
  p = input().split()

for i in range(N):
    p[i] = int(p[i])
    
if N == 0:
    print(X)
else:    
    for i in range(2*N):
        if not (X-i) in p:
            print(X-i)
            break
        elif not (X+i) in p:
            print(X+i)
            break
        else:
          continue

Solution (Python):
X, N = map(int, input().split())
li = [i for i in map(int, input().split())]
k = 0
ans = 1000
while X-k >= 0 or X + k <= N:
    if X - k not in li:
        ans = X - k
        break
    if X+k not in li:
        ans = X+k
        break
    k += 1
print(ans)

Solution (Python):
X, N = map(int, input().split())
p = set(map(int, input().split()))
def main():
    if X not in p:
        print(X)
        return
    for i in range((N-1)//2+2):
        if X-i not in p:
            print(X-i)
            break
        elif X+i not in p:
            print(X+i)
            break

main()

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

i = 0
while True:
    x_i = x - i
    x_j = x + i

    if x_i not in p_list:
        print(x_i)
        exit()
    if x_j not in p_list:
        print(x_j)
        exit()

    i += 1

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

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

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

n_p = []

for i in range(-1, 102):
    if i in p:
        continue
    else:
        n_p.append(i)


dif = float("inf")
for i in range(len(n_p)):
    if dif > abs(x - n_p[i]):
        dif = abs(x - n_p[i])
        ans = n_p[i]

print(ans)

Solution (Python):
x,n = map(int,input().split())
if n != 0:
    p_list = list(map(int,input().split()))
    num_list = []
    num_list.append(x)
    for i in range(1,51):
        num_list.append(x-i)
        num_list.append(x+i)
    flag = True
    for i in num_list:
        if flag == False:
            break
        if i not in p_list:
            ans = i
            flag = False
    print(ans)
else:
    print(x)

Solution (Python):
import sys

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

if not (X in p):
    print(X)
    sys.exit(0)

i = 1
while 1:
    if not (X-i in p):
        print(X-i)
        sys.exit(0)
    if not (X+i in p):
        print(X+i)
        sys.exit(0)
    i += 1

Solution (Python):
x,n=map(int, input().split())
if(n==0):
  print(x)
else:
  hoge=list(map(int, input().split()))
  ans=0
  flag=0
  val=9999
  for i in range(102):
    if(i in hoge):
      flag+=1
    else:
      if(val>abs(x-i)):
        val=abs(x-i)
        ans=i
  print(ans)

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

res = -1
i=0
while(res==-1):
    check_low = X - i
    if check_low not in p:
        res = check_low
    else:
        check_high = X + i
        if check_high not in p:
            res = check_high
    i += 1

print(res)

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

Solution (Python):
def main():
    X,N = map(int,input().split())
    if N != 0:
        P = list(map(int,input().split()))
        
        p = [i for i in range(-200,200)]
        q = []
        for i in range(N):
            if not P[i] in q:
                p[p.index(P[i])] = 201
                q.append(P[i])
        
        
        ans = abs(X-p[0])
        ans_p = 0
        for i in range(1,len(p)):
            if abs(X-p[i]) < ans \
            or (abs(X-p[i]) == ans and p[i] < ans_p):
                ans = abs(X-p[i])
                ans_p = p[i]
                
        print(ans_p)
        
    else:
        print(X)
    
if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


x, n = MI()
pl = list(MI())

nums = set(list(range(102))) - set(pl)

dmin = 1000000
for p in nums:
    d = abs(x - p)
    if d < dmin:
        temp = []
        temp.append(p)
        dmin = d
    elif d == dmin:
        temp.append(p)

print(min(temp))

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
if X not in p:
    print(X)
    exit()
judge = [False] * 102
for pi in p:
    judge[pi] = True
now = 1
Flag = False
while not Flag:
    if not judge[X - now]:
        print(X - now)
        Flag = True
    elif not judge[X + now]:
        print(X + now)
        Flag = True
    else:
        now += 1

Solution (Python):
x,n=map(int,input().split())
p = list(map(int,input().split()))
p.sort()
b = []
for i in range(0,102):
    if not (i in p):
        b.append((i,abs(i-x)))

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

Solution (Python):
x,n = map(int,input().split())
P = list(map(int,input().split()))
A = []
a = 0
for i in range(200):
    if x+a in P:
        a += 1
    else:
        A.append(x+a)
        break
a = -1
for i in range(200):
    if x+a in P:
        a -= 1
    else:
        A.append(x+a)
        break

if abs(x-A[0]) < abs(x-A[1]):
    print(A[0])
    exit()
elif abs(x-A[0]) > abs(x-A[1]):
    print(A[1])
    exit()
else:
    print(min(A[0],A[1]))

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

m=100100100
ans=-1
for i in range(1000):
    if(i in p):continue
    if(m>abs(i-x)):
        m=abs(x-i)
        ans=i
print(ans)

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

p.sort()

if X in p:
    ind=p.index(X)
    i=1
    while True:
        if (X-i) in p and (X+i) in p :
            i+=1
        elif (X-i) not in p:
            print(X-i)
            break
        else:
            print(X+i)
            break
else:
    print(X)

Solution (Python):
x, n = [int(s) for s in input().split()]
p_set = set([int(s) for s in input().split()])
if x not in p_set:
    print(x)
    exit()
l = x - 1
while l in p_set:
    l -= 1
r = x + 1
while r in p_set:
    r += 1
print(l if abs(x - l) <= abs(x - r) else r)

Solution (Python):
x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
else:
    p = []
ans = 1000
x1 = x
x2 = x
while ans == 1000:
    if p.count(x1) == 0:
        ans = x1
    if p.count(x2) == 0:
        ans = min(ans,x2)
    x1 += 1
    x2 -= 1
print(ans)

Solution (Python):
x, n = map(int, input().split())
if n==0:
    print(x)
    exit()
*p, = map(int, input().split())
num = 0
while True:
    if x-num not in p:
        print(x-num)
        exit()
    elif x+num not in p:
        print(x+num)
        exit()
    num += 1

Solution (Python):
X, N = (int(i) for i in input().split())  
if N == 0:
  print(X)
  exit()
P = [int(i) for i in input().split()] 

d = 0

while True:
  num = X - d
  if num not in P:
    print(num)
    exit()
    
  num = X + d
  if num not in P:
    print(num)
    exit()
  
  d += 1

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

for i in range(-1, 103):
    if i not in p:
        tmp.append((abs(i - x), i))

print(min(tmp)[1])

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

d = 10**10
v = 10**10
for i in range(0, 102):
    if i in P:
        continue
    _d = abs(X - i)
    
    if _d < d:
        d = _d
        v = i
    if _d == d:
        v = min(i, v)
print(v)

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

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

num = 0

while True:
    if x-num not in forbidden_list:
        print(x-num)
        break

    if x+num not in forbidden_list:
        print(x+num)
        break

    num += 1

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

Solution (Python):
x,n = map(int,input().split())
ps = list( map(int,input().split()))
prob = [True]*103

for p in ps:
    prob[p+1] = False

ans = 200

for i in range(102,-1,-1):
    if prob[i]:
        if abs(ans - x) >= abs(i-1-x):
            ans = i-1

print(ans)

Solution (Python):
x, n = map(int,input().split())
if n != 0:
  a = list(map(int,input().split()))
b = [i for i in range(-150,150)]
c = 1000

for i in range(n):
    b.remove(a[i])

for i in range(len(b)):
  if abs(b[i] - x) < abs(c - x):
      c = b[i]
  else:
      pass

print(c)

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


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

S = set([i for i in range(102)])
S = S - P

ans = -1
diff = INF
for s in sorted(S):
    if abs(s - X) < diff:
        ans = s
        diff = abs(s - X)

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')

def main():
    MAX = 10000
    X, N = MI()
    P = LI()
    ans = {}
    for i in range(102):
        ans[i] = i
    for p in P:
        ans[p] = MAX
    answer = MAX
    ab = MAX
    for i in range(102):
        if ans[i] == MAX:
            continue
        if ab > abs(ans[i] - X):
            ab = abs(ans[i] - X)
            answer = i
    print(answer)


if __name__ == '__main__':
    main()

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

p = list(map(int , input().split()))
ps = set(p)
o = []
for i in range(110):
    if i in ps:
        continue
    o.append(i)

m = 1000
ans = -1
for oi in reversed(o):
    if abs(x - oi) <= m:
        ans = oi
        m = abs(x - oi)

print(ans)

Solution (Python):
x,n=map(int,input().split())
p=input().split()
if p.count(str(x))==0:
  print(x)
  exit()
i=1
while True:
 x=x-i
 if p.count(str(x))==0:
  print(x)
  exit()
 x=x+2*i
 if p.count(str(x))==0:
  print(x)
  exit()
 x=x-i
 i=i+1

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

Solution (Python):
import sys
import os
import itertools
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

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

        i=1
        if not X in p:
            print(X)
        else:
            while True:
                if not X-i in p:
                    print(X-i)
                    break
                if not X+i 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)
    exit()


P = list(map(int, input().split()))
A = []
for a in range(-1, 102):
    A.append(a)

for a in P:
    A.remove(a)

if X not in P:
    print(X)
    exit()
else:
    A.append(X)

A.sort()
C = A.index(X)
D = A[C+1]
E = A[C-1]

if D-X == X-E:
    print(E)
elif D-X > X-E:
    print(E)
else:
    print(D)

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

pp = set(pp)

for i in range(102):
    if not X-i in pp:
        print(X-i)
        exit(0)
    if not X+i in pp:
        print(X+i)
        exit(0)

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
p1=list(range(-150,150))
l= set(p) ^ set(p1)

for i in range(150-x):
    if x-i in l:
        print(x-i)
        exit()
    if x+i in l:
        print(x+i)
        exit()

Solution (Python):


X, N = map(int, input().split())
P = list(int(p) for p in input().split())
P = set(P)
INF = 10**18

ans = 0
tmp = INF
for i in range(102):
    if i not in P:
        if abs(i-X) < tmp:
            tmp = abs(i-X)
            ans = i

print(ans)

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

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

Solution (Python):
def resolve():
    x, n = map(int, input().split())
    P = []
    while 1:
        try:
            k = map(int, input().split())
            P.extend(k)
        except EOFError:
            break

    if P == []:
        print(x)
        return

    P = set(P)

    diff = 0

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

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

    
    nglist = [0] * 102
    for i in range(n):
        nglist[p[i]] = 1

    
    minval = 10000
    ans = -1
    for i in range(0, 102):
        wkmin = abs(x - i)
        if nglist[i] == 0 and wkmin < minval:
            minval = wkmin
            ans = i


print(ans)