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):
def solve():
    x,n=map(int,input().split())
    if not n==0:
        p=list(map(int,input().split()))
    else:
        print(x)
        return
    
    for i in range(0,100):
        
        if not (x-i) in p:
            print(x-i)
            return
        
        if not (x+i) in p:
            print(x+i)
            return
        
        
solve()

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans1, ans2 = x, x
cnt1, cnt2 = 0, 0
while ans1 in p:
    ans1 += 1
    cnt1 += 1
while ans2 in p:
    ans2 -= 1
    cnt2 += 1
if cnt1 >= cnt2:
    print(ans2)
else:
    print(ans1)

Solution (Python):
X, N = map(int, input().split(' '))
P = list(map(int, input().split(' '))) if N else []
ans = 102
for i in range(102,-2,-1):
    if i not in P:
        ans = i if abs(ans-X) >= abs(i-X) else ans
print(ans)

Solution (Python):
X,N=map(int,input().split())
P=list(map(int,input().split()))
if X not in P:
    print(X)
    exit()
d=1
while True:
    a=X-d
    b=X+d
    if a not in P:
        print(a)
        break
    if b not in P:
        print(b)
        break
    d+=1

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

p=set(p)
ans=1000
for i in range(x+100):
    if i not in p:
        if abs(ans-x)>abs(i-x):
            ans=i
print(ans)

Solution (Python):
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

X,N = mips()
P = [i for i in mips()]
A = []
c1 = -1
c2 = -1
for i in range(100):
    if c1 == 1 and c2 == 1:
        break
    a1 = X-i
    a2 = X+i
    if c1 == -1 and a1 not in P:
        A.append(a1)
        c1 = 1
    if c2 == -1 and a2 not in P:
        A.append(a2)
        c2 = 1
ans = 1000
B = []
for el in A:
    if abs(ans-X) >= abs(el-X):
        ans = el
        B.append(ans)
print(min(B))

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

def slove():
    x, n = map(int,input().split())
    p = list(map(int,input().split()))
    for i in range(101):
        if x-i not in p:
            print(x-i)
            break
        if x+i not in p:
            print(x+i)
            break

if __name__ == "__main__":
    slove()

Solution (Python):


def ans(P, X):
    P = set(P)
    for i in range(200):
        if X - i not in P:
            return X-i 
        if X + i not in P:
            return X+i

X, N = input().split(' ')
X = int(X)
N = int(N)
if N == 0:
    print(X)
else:
    P = input().split(' ')
    P = [int(x) for x in P]

    print(ans(P, X))

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

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

'''

'''

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

l, r = x,x 

if not(x in p):
    print(x)
else:
    while True:
        if not(l in p):
            print(l)
            break
        elif not(r in p):
            print(r)
            break

        l -= 1
        r += 1

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

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



c = 0
while True:
    if not x - c in p:
        print(x-c)
        exit()
    
    elif not x + c in p:
        print(x+c)
        exit()
    
    c += 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()]
if not X in p:
    print(X)
    exit()
for i in range(1,100):
    if not X-i in p:
        print(X-i)
        exit()
    if not X+i in p:
        print(X+i)
        exit()

Solution (Python):
x, n = map(int, input().split())
p = list(map(int ,input().split()))
p.sort()
ans = []
for i in range(100):
    x_left = x-i
    x_right = x + i
    if x_left not in p:
        print(x_left)
        exit()
    elif x_right not in p:
        print(x_right)
        exit()

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

Solution (Python):
x, n = map(int, input().split())
P = list(map(int, input().split()))
ans_sma = x
ans_lar = x
while True:
    if ans_sma not in P:
        print(ans_sma)
        break
    elif ans_lar not in P:
        print(ans_lar)
        break
    ans_sma -= 1
    ans_lar += 1

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

i = 0
while (x + i in p) and (x - i) in p:
    i += 1

if x - i not in p:
    print(x - i)
else:
    print(x + i)

Solution (Python):
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
P=list(map(int,input().split()))
f=10**10
ans=0
for i in range(-120,220):
  if i not in P:
    a=abs(x-i)
    if a<f:
      f=a
      ans=i
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    x,n=MI()
    pp=set(MI())
    for d in range(100):
        if x-d not in pp:
            ans=x-d
            break
        if x+d not in pp:
            ans=x+d
            break
    print(ans)

main()

Solution (Python):
x,n = map(int, input().split())
P = sorted(list(map(int, input().split())))
tmp = 0
for i in range(100):
    if x-tmp not in P:
        print(x-tmp)
        exit()

    elif x + tmp not in P:
        print(x+tmp)
        exit()
    tmp +=1

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

for i in range(2*n+1):
    a=x-i
    b=x+i

    if a not in p:
        m=a
        break
    if b not in p:
        m=b
        break
print(m)

Solution (Python):
from collections import defaultdict

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

plist = map(int, input().split())

pdict = defaultdict(int)

for p in plist:
    pdict[p] = 1



if pdict[x] == 0:
    print(x)
    exit(0)

z = 1


while True:
    if pdict[x - z] == 0:
        print(x - z)
        exit(0)
    if pdict[x + z] == 0:
        print(x + z)
        exit(0)
    z += 1

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
if n!=0:
    for i in range((max(p)+3)**2):
        num=x+i in p
        num2=x-i in p
        if num2==False:
            ans=x-i
            break
        if num==False:
            ans=x+i
            break
else:
    ans=x
print(ans)

Solution (Python):
X, N = map(int, input().split())
A = list(map(int, input().split()))
for i in range(110):
  s = X - i
  t = X + i
  if s not in A:
    print(s)
    exit()
  if t not in A:
    print(t)
    exit()

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

X,N = map(int,S().split())
p = LI()
p = sorted(p)

for i in range(N+2):
    if not (X-i in p):
        print(X-i)
        exit()
    if not (X+i in p):
        print(X+i)
        exit()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        exit()
    else:
        P = set(map(int, input().split()))
    for i in range(100):
        x2 = X - i
        if x2 not in P:
            print(x2)
            exit()
        x1 = X + i
        if x1 not in P:
            print(x1)
            exit()

if __name__ == '__main__':
    main()

Solution (Python):



import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf



import math

import bisect

def solve(x, s):
    d = 0
    while d < 200: 
        v = x - d
        if v not in s:
            return v
        v = x + d
        if v not in s:
            return v
        d += 1
    raise RuntimeError


if __name__ == '__main__':
    x, n = list(map(int, input().split()))
    if n == 0:
        print(x)
    else:
        s = set(map(int, input().split()))
        ans = solve(x, s)
        print(ans)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

X, N = map(int, input().split())
A = []
if N != 0:
    A = set(map(int, input().split()))

ans = 0
d = 1 << 28
for i in range(200):
    if i not in A and abs(X - i) < d:
        ans = i
        d = abs(X - i)

print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    ans = float("inf")
    ans_m = float("inf")
    for i in range(-10, 110):
        if i not in P:
            if abs(X-i) < ans_m:
                ans_m = abs(X-i)
                ans = i
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import bisect
MOD = 10**9+7

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

def ii():
    return int(input())

def main():
    X, N = mi()
    p = list(mi())
    i = 0
    while True:
        if not X-i in p:
            print(X-i)
            return
        if not X+i in p:
            print(X+i)
            return
        i += 1

if __name__ == '__main__':
    main()

Solution (Python):
x,n=map(int,input().split())
P=sorted(list(map(int,input().split())))
if n==0:print(x);exit()
ans=10**9
add=0
point=-1
for i in range(-100,200):
    if i==P[add]:
        if add!=n-1:add +=1
        continue
    else:
        if abs(i-x)<ans:
            point=i
            ans=abs(i-x)
print(point)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
S = set(map(int,input().split()))
for i in range(300):
    y = x-i
    if not y in S:
        print(y)
        break
    z = x+i
    if not z in S:
        print(z)
        break

Solution (Python):
X,N = map(int,input().split())
if N > 0:
  P = input().split()
  P = [int(x) for x in P]
else:
    P = []

ans = 101
s = 101-X
for i in range(101)[::-1]:
  a = abs(i - X)
  if a <= s:
    if not(i in P):
      ans = i
      s = a

print(ans)

Solution (Python):
import numpy as np

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

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

qq = set(range(102))

cand = np.array(sorted(list(qq-pp)))

print(cand[abs(cand - x).argmin()])

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    X, N = LI()
    p = LI()

    sa = 1000000
    ans = 0
    for i in range(102):
        if abs(i-X) < sa and (not i in p):
            sa = abs(i-X)
            ans = i
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
from decimal import Decimal

def main():

    input = stdin.readline

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

    ans = X

    if ans not in P:
        print(ans)
        return


    for i in range(1,100):
        if ans - i not in P:
            print(ans - i)
            return
        elif ans + i not in P:
            print(ans + i)
            return

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    high = x
    low = x
    while(1):
        if low not in p:
            print(low)
            return
        if high not in p:
            print(high)
            return
        low -= 1
        high +=1






x, n  = RA()
if n:
    p = set(RA())
else:
    p = set()
solve()

Solution (Python):
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    X, N = in_nn()
    p = list(in_nn())

    ans = 1000
    for i in range(-5, 105):
        if i in p:
            continue
        else:
            if abs(X - i) < abs(X - ans):
                ans = i

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
X, N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
min_abs = 100
for i in range(102):
    if i not in p:
        min_abs = min(min_abs, abs(X-i))

if X - min_abs not in p:
    print(X - min_abs)
else:
    print(X + min_abs)

Solution (Python):
x,n=map(int,input().split())
b=float("INF")
ans=0
l=set(map(int,input().split()))
for i in range(-100,200):
    if i in l:continue
    if b>abs(x-i):
        b=abs(x-i)
        ans=i
print(ans)

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

if N == 0:
  print(X)
  import sys
  sys.exit()
  
i = 0
while 1:
  if (X-i) not in p:
    print(X-i)
    break
  elif (X+i) not in p:
    print(X+i)
    break
  else:
    i += 1

Solution (Python):
X,N=map(int,input().split())
p=list(map(int,input().split()))
s = set(p)
i=0
ans = X
found=False
while not found:
    if X+i not in s:
        ans = X+i
        found = True
    if X-i not in s:
        ans=X-i
        found = True
    i+=1
print(ans)

Solution (Python):
X,N=map(int,input().split())
if N==0:
    print(X)
else:
    a = list(map(int,input().split()))
    res = 10**9
    mi = 10**9
    for val in range(200,-100,-1):
        if val not in a:
            tmp = abs(X-val)
            if res >= tmp:
                res = tmp
                mi = val
    print(mi)

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

pli = set(map(int,input().split()))
i = 0

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

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

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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

x,n=map(int,input().split())
p=[int(i) for i in input().split()]
ans=0
ansc=100000
for i in range(-200,200):
    if i not in p:
        
        if ansc>abs(i-x):
            ans=i
            ansc=abs(i-x)
        elif ansc==abs(i-x):
            if ans>i:
                ans=i
print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
INF = float("inf")


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

    ans = INF
    for n in range(110):
        if n in p:
            continue
        if abs(n-X) < abs(ans-X):
            ans = n

    print(ans)

    return


if __name__ == '__main__':
    main()

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

ls = [0]*(102)
for p in P:
    ls[p] = 1

for i in range(101):
    L, R = X-i, X+i
    if ls[L] == 0:
        print(L)
        break

    if ls[R] == 0:
        print(R)
        break

Solution (Python):
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

x, n = map(int, input().split())
if n!=0: nums = set(map(int, stdin.readline().split()))

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

ans = 10**9
for i in range(10000):
    t1 = x + i if x+i not in nums else 10**4
    t2 = x - i if x-i not in nums else 10**4
    if t1!=10**4 or t2!=10**4:
        ans = min(t1, t2)
        print(ans)
        exit()

Solution (Python):

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

p.sort()
inf=float("inf")
min_dif =inf
ret=None

for i in range(102):
    if i in p:
        continue
    if abs(x-i)<min_dif:
        min_dif=abs(x-i)
        ret=i

print(ret)

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

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

i = 0
flag = 0

while(True):
    if(not((X-i) in p)):
        flag = -1
        break
    if(not((X+i) in p)):
        flag = 1
        break
    i += 1

print(X + i * flag)

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

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    X, N, *P = map(int, read().split())
    P = set(P)
    Q = [i for i in range(-10, 110) if i not in P]
    Q.sort()
    error = INF
    for q in Q:
        if abs(X-q) < error:
            ans = q
            error = abs(X-q)
    
    print(ans)
    return


if __name__ == '__main__':
    main()

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

ans_abs = abs(X - 300)
ans = 300

for i in range(-300,300):
    if i not in p_set:
        if abs(X - i) < ans_abs:
            ans_abs = abs(X - i)
            ans = i

print(ans)

Solution (Python):
def main():
    x, n = list(map(int, input().split()))
    if n == 0:
        print(x)
        exit()
    else:
        P = list(map(int, input().split()))
    S = set(range(102)) - set(P)
    ans = float('inf')
    ans_p = 0
    for s in S:
        r = abs(s - x)
        if r < ans:
            ans = r
            ans_p = s
        elif r == ans:
            if ans_p > s:
                ans_p = s
    print(ans_p)
if __name__ == '__main__':
    main()

Solution (Python):
import sys

X,N=[int(i) for i in input().split(" ")]
if N==0:
    print(X)
    sys.exit(0)
p=[int(i) for i in input().split(" ")]

i=0
while True:
    if (X-i in p)==False:
        print(X-i)
        sys.exit(0)
    elif (X+i in p)==False:
        print(X+i)
        sys.exit(0)
    else:
        i+=1

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


def answer():
    d = 0

    while True:
        if x - d not in p:
            return x - d
        if x + d not in p:
            return x + d
        d += 1


print(answer())

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

if not x in p:
  print(x)
else:
  for i in range(1,100):
    if not x-i in p:
      print(x-i)
      break
    if not x+i in p:
      print(x+i)
      break

Solution (Python):
x, n = list(map(int, input().split()))
al = list(map(int, input().split()))
INF = float("inf")
ans = INF
sa = INF
for i in range(102):
    if i not in al:
        if sa > abs(x-i):
            sa = abs(x-i)
            ans = i
print(ans)

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

ab = 0
while 1:
    if not(X-ab in p):
        print(X-ab)
        break
    if not(X+ab in p):
        print(X+ab)
        break
    ab+=1

Solution (Python):
import sys
mina=10**10
X,N=map(int,input().split())
if N==0:
  print(X)
  sys.exit()
L=list(map(int,input().split()))
for i in range(52):
  if X-i not in L:
    print(X-i)
    sys.exit()
  if X+i not in L:
    print(X+i)
    sys.exit()

Solution (Python):
from collections import Counter

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

if not(X in c):
    print(X)
    exit(0)

for i in range(200):
    tmp1 = X-i
    if not(tmp1 in c):
        print(tmp1)
        exit(0)

    tmp2 = X+i
    if not(tmp2 in c):
        print(tmp2)
        exit(0)

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

Solution (Python):
x,n = map(int,input().split())
a = sorted(list(map(int,input().split())))
dif = 10**10
ans = -1
for i in range(102):
    if not i in a:
        if dif>abs(x-i):
            dif = abs(x-i)
            ans = i

print(ans)

Solution (Python):
x,n = map(int,input().split())
l = list(map(int,input().split()))
ans = 10**10
if n == 0:
    print(x)
    exit()
for i in range(-100,1000):
    if i in l:
        continue
    if ans > abs(i-x):
        ans1 = i
        ans = abs(i-x)
print(ans1)

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

    SA=10**9
    num=-10**9
    for i in range(102):
        if i not in p:
            if abs(X-i)<SA:
                SA=abs(X-i)
                num=i
    print(num)
else:
    print(X)

Solution (Python):
x,n=map(int, input().split())
p = list(map(int, input().split()))
p=sorted(p)
last=1000
zettai=1000
for i in range(102, -1, -1):
    if i not in p:
        if zettai>=abs(i-x):
            zettai=abs(i-x)
            last=i
print(last)

Solution (Python):
num,length = list(map(int,input().split()))
if length != 0:
  lst = list(map(int,input().split()))
else:
  pass

if length == 0:
  print(num)
else:
  sett = set(lst)
  for i in range(100):
    if not (num-i in lst):
      print(num-i)
      break
    if not (num+i in lst):
      print(num+i)
      break

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

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

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

x,n = get_nums_l()
if n == 0:
    print(x)
    exit()
P = set(get_nums_l())

log(P)

min_ = INF
ans = INF

for a in range(-1, 102):
    if a not in P:
        y = abs(x-a)
        
        if y < min_:
            min_ = y
            ans = a

print(ans)

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

for i in range(102):
  xl = x - i
  xr = x + i
  if xl not in P:
    print(xl)
    break
  elif xr not in P:
    print(xr)
    break

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

P.sort()
for d in range(101):
    r = X + d
    l = X - d
    if l not in P:
        ans = l
        break
    if r not in P:
        ans = r
        break

print(ans)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    x,n=INTM()
    p=LIST()
    
    for i in range(101):
        if not x-i in p:
            print(x-i)
            break
        if not x+i in p:
            print(x+i)
            break
        
            
    
if __name__ == '__main__':
    do()

Solution (Python):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input().split()))
ans = float('inf')

for i in range(102):
    if i in P:
        continue
    if abs(ans - X) > abs(i - X):
        ans = i

print(ans)

Solution (Python):
def main():
    X, N = map(int, input().split())
    A = list(map(int, input().split()))
    A_s = set(A)
    candidate = []
    for i in range(-1, 102):
        if i not in A_s:
            candidate.append(i)

    ans = 10**6
    ans_val = 0
    for c in candidate:
        temp = abs(c-X)
        if temp < ans:
            ans = temp
            ans_val = c
    print(ans_val)

        
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    X, N = (int(i) for i in input().split())
    P = {int(i) for i in input().split()}

    for i in range(200):
        if X-i not in P:
            print(X-i)
            break
        if X+i not in P:
            print(X+i)
            break


if __name__ == '__main__':
    main()

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

ans = 0

for i in range(1000):
    if x - i not in p:
        ans = x - i
        break
    elif x + i not in p:
        ans = x + i
        break

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
X, N = map(int, input().split())
a = set(list(map(int, input().split())))
res = 0
for i in range(400):
  x = i - 200
  if x in a: continue
  if abs(res - X) > abs(x - X): res = x
print(res)

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


diff=float('inf')
ans=-1
for i in range(-100,110):
    if i in P:
        continue
    d = abs(X-i)
    if d<diff:
        diff=d
        ans=i
print(ans)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

ans = 1e9
for i in range(-105, 105):
    if i in P_set:
        continue
    if abs(ans - X) > abs(i - X):
        ans = i
print(ans)

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

def solve():
    X, N = map(int, readline().split())
    P = list(map(int, readline().split()))

    a = set(P)

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

solve()

Solution (Python):
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    x, n = _ia()
    p = {i: 1 for i in _ia()}

    for i in range(101):
        if p.get(x-i) is None:
            return x-i
        if p.get(x+i) is None:
            return x+i


if __name__ == "__main__":
    print(main())

Solution (Python):
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    X, N= list(map(int, _in[0].split(' ')))  
    try:
        p_arr = list(map(int, _in[1].split(' ')))  
    except:
        p_arr = []
    
    cnt = float('inf')
    memo = None

    abs_ = 0
    while True:
        if X-abs_ not in p_arr:
            ans = X-abs_
            break
        if X+abs_ not in p_arr:
            ans = X+abs_
            break
        abs_ += 1
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    *p, = map(int, input().split())
    ans = -1
    d = 10**10
    for i in range(-101, 102):
        if i in p:
            continue
        m = abs(i-X)
        if m < d:
            d = m
            ans = i
    print(ans)

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

Solution (Python):
x, n = map(int, input().split())
p_list = [int(i) - x for i in input().split()]
p_list.sort()
for i in range(200):
    if i * (-1) not in p_list:
        print(i * (-1) + x)
        exit()
    elif i not in p_list:
        print(i + x)
        exit()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



X, N = MAP()
p = LIST()

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

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

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