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())
sw = 1
if n == 0:
    sw = 0
    ans = x
else:
    p = list(map(int,input().split()))
    y1 = x
    y2 = x
    ans = 0
    for i in range(n):
        if y1 in p and not(y2 in p):
            ans = y2
            break
        elif y2 in p and not(y1 in p) :
            ans = y1
            break
        elif y1 in p and y2 in p:
            y1 -= 1
            y2 += 1
        else:
            ans = min(y1,y2)
            break
print(ans)

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

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

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

Solution (Python):

import collections
import itertools as it
import math

 


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




li = []
for i in range(-1000, 1001):
    if not i in p:
        li.append(i)

ans = 1000
min_ = 1000
for i, l in enumerate(li[::-1]):
    if min_ >= abs(x - l):
        min_ = abs(x - l)
        ans = l

print(ans)

Solution (Python):


import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

X, N = LI()
P = LI()

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

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

if n == 0:
    print(x)
else:
    p = {int(_) for _ in input().split(' ')}

    answer = 0
    m = 102
    for i in range(102):
        if not(i in p) and abs(x - i) < m:
            answer = i
            m = abs(x - i)
    print(answer)

Solution (Python):
import bisect
x,n = map(int, input().split())
if (n==0):
    print(x)
    exit()
p = list(map(int, input().split()))
a = []
for i in range(102):
    if (i in p):
        continue
    a.append(i)



z = bisect.bisect_left(a,x)
if (z==0):
    print(a[0])
    exit()
elif (z==len(a)):
    print(a[-1])
    exit()
a1 = a[z]
a2 = a[z-1]
if (abs(a1-x) < abs(a2-x)):
    print(a1)
elif (abs(a1-x) > abs(a2-x)):
    print(a2)
else:
    print(a2)

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

Solution (Python):
X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  P = list(map(int, input().split()))
  for d in range(100):
    if X - d not in P:
      print(X - d)
      break
    if X + d not in P:
      print(X + d)
      break

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



def main():
    X, N = [int(i) for i in input().strip().split()]
    p_list = [int(i) for i in input().strip().split()]

    base = list()
    for i in range(-110, 110):
        if i not in p_list:
            base.append(i)

    dif = float("inf")
    ans = None
    for j in base:
        if abs(j - X) < dif:
            dif = abs(j-X)
            ans = j

    return ans


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

Solution (Python):
x, n = map(int,input().split())
li = list(map(int,input().split()))
ans = []

for i in range(n):
    ans.append(abs(li[i]-x))

ans.sort()
if 0 not in ans:
    print(x)
else:
    for i in range(1,1000):
        if ans.count(i) == 0:
            print(x-i)
            exit()
        elif ans.count(i) == 1:
            if x+i in li:
                print(x-i)
            else:
                print(x+i)
            exit()

Solution (Python):




import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    ans=99999
    ansd=99999
    x,n=map(int, readline().rstrip().split())

    if n==0:
        print(x)
        return

    p=list(map(int, readline().rstrip().split()))
    for i in range(103):
        if i in p:
            continue
        d=abs(x-i)
        if d < ansd:
            ans=i
            ansd=d

    print(ans)
    
    
    

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

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

    s = x
    t = x
    while True:
        if t not in p:
            print(t)
            break
        elif s not in p:
            print(s)
            break
        else:
            s += 1
            t -= 1

if __name__ == "__main__":
    main()

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

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

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

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

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

l=list(range(102))

for i in range(n):
  l.remove(p[i])


ans=0
dif=1000

for i in range(102-n):
  temp=abs(l[i]-x)
  if temp<dif:
    dif=temp
    ans=l[i]
print(ans)

Solution (Python):

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


fresh = [True] * 102 
if(N > 0):
    for i in range(N):
        fresh[P[i]] = False 



min_diff = 1000
ans = 0
l = []

for i in range(102):
    if(fresh[i]):
        l.append(abs(X-i))
    else:
        l.append(10000)
print(l.index(min(l)))



'''
for i in range(100):
    if(fresh[i]):
        
        diff = abs(X - (i+1))
        if(min_diff )
'''

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

a = X
b = X
if X not in p:
    print(X)
    exit()
for i in range(1000):
    a -= 1
    b += 1
    if a not in p:
        print(a)
        break
    elif b not in p:
        print(b)
        break

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

p=list(map(int,input().split()))
for i in range(x,110):
  if 2*x-i not in p:
    print(2*x-i)
    sys.exit()
  if i not in p:
    print(i)
    sys.exit()

Solution (Python):


import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    m,n=map(int,input().split())
    a = [int(x) for x in input().split()]
    ans=-(1<<30)
    for i in range(m-200,m+200):
        if i in a:
            continue
        if abs(i-m)>=abs(ans-m):
            continue
        ans=i
    print(ans)



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):
def main():
    X, N = list(map(int, input().split(' ')))
    if N == 0:
        P = input()
        print(X)
        return
    P = list(map(int, input().split(' ')))
    min_dist, ans = abs(X), 0
    for n in range(102):
        if n in P:
            continue
        if abs(X - n) < min_dist:
            min_dist = abs(X - n)
            ans = n
    print(ans)


if __name__ == '__main__':
    main()

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

diff= 1000
ans = 0
for i in range(102):
  if i in P: continue
  if abs(x-i)<diff:
    diff = 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()))
l = [i for i in range(102)]
for i in p:
    l.remove(i)
a = 100
for i in l:
    a = min(a,abs(x-i))
for i in l:
    if abs(x-i) == a:
        print(i)
        exit()

Solution (Python):
X,N = map(int, input().split())
if N != 0:
    s=set(list(map(int, input().split())))
else:
    s=set([])
    
if X not in s:
    print(X)
else:
    for i in range(1, 101):
        if X-i not in s:
            print(X-i)
            break
        if X+i not in s:
            print(X+i)
            break

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

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
left = 10**9
right = 10**9
i = x
while True:
    if not i in p:
        left = abs(i - x)
        break
    i -= 1
i = x
while True:
    if not i in p:
        right = abs(i - x)
        break
    i += 1
if left == right:
    print(x - left)
elif left < right:
    print(x - left)
else:
    print(x + right)

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

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

answer_numbers = [[1, 1] for i in range(101)]

for i in range(len(p_i)):
    if x - p_i[i] == 0:
        answer_numbers[0][0] = 0
        answer_numbers[0][1] = 0

    elif x - p_i[i] > 0:
        answer_numbers[abs(x-p_i[i])][0] = 0
    elif x - p_i[i] < 0:
        answer_numbers[abs(x-p_i[i])][1] = 0

for i in range(len(answer_numbers)):
    if not answer_numbers[i] == [0, 0]:
        if answer_numbers[i][0] == 1:
            print(x - i)
            break
        elif answer_numbers[i][1] == 1:
            print(x + i)
            break

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

value_num = X
value_NUM = X

while 1:
    if not(value_num in p):
        print(value_num)
        break

    if not(value_NUM in p):
        print(value_NUM)
        break

    
    

    value_num -= 1
    value_NUM += 1

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

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

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

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

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

DIFF = 200
ans = 200

for p in range(0, 102):
    if p in P:
        continue

    d = abs(X - p)

    if d == DIFF:
        ans = min(p, ans)
    elif d < DIFF:
        DIFF = d
        ans = p

print(ans)

Solution (Python):
x,n = map(int,input().split())
if n != 0:
    P = list(map(int,input().split()))
else:
    P = []
tmp = 999
ans = 0
for i in range(-1,102):
    if tmp > abs(x-i):
        if not i in P:
            tmp = abs(x-i)
            ans = i
print(ans)

Solution (Python):
X,N = list(map(int,input().split()))
if N == 0:
  P = []
else:
  P = list(map(int,input().split()))
MIN = float('inf')
MINLIST = []
for i in range(-1000,1000):
    if i not in P and abs(X-i) <= MIN:
        if abs(X-i) == MIN:
            MINLIST.append(i)
        else:
            MIN = abs(X-i)
            MINLIST = [i]
print(min(MINLIST))

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

for i in range(200):
    if X-i not in P:
        print(X-i)
        exit()
    elif X+i not in P:
        print(X + i)
        exit()
    else:
        continue

print(X)

Solution (Python):
X, N = map(int, input().split())
P = set(map(int, input().split()))
ans = 0
for i in range(102):
    if i in P:
        continue
    if abs(X-ans) > abs(X-i):
        ans = i
print(ans)

Solution (Python):
def solve():
    x, n = map(int, input().split(" "))
    if n == 0 :
        return x
    if x < 0 :
        return x-1
    elif x >= 102 :
        return x-1
    
    used = [False]*102
    for p in map(int, input().split(" ")):
        used[p]=True
    
    _min = float('inf')
    ans = 0
    for i in range(0, 102):
        if used[i] :
            continue
        if abs(i-x) < _min :
            _min = abs(i-x)
            ans = i
    
    return ans

print(solve())

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

d = 0
while True:
    for sgn in [-1, 1]:
        x = X + sgn * d
        if x not in p:
            break
    else:
        d += 1
        continue
    break
print(x)

Solution (Python):
x,n = map(int,input().split())
if n > 0:
  a = list(map(int,input().split()))
else:
  a = []
a = set(a)
ans = x
for i in range(100):
  if not x-i in a:
    print(x-i)
    break
  if not x+i in a:
    print(x+i)
    break

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

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

    nums = [i for i in range(-200, 200)]

    for i in range(N):
        nums.remove(p[i])
        
    min_diff = 1000
    min_index = 1000

    for i in range(len(nums)):
        if abs(X - nums[i]) < min_diff or (abs(X - nums[i]) == min_diff and nums[min_index] > nums[i]):
            min_diff = abs(X-nums[i])
            min_index = i

    print(nums[min_index])


if __name__ == '__main__':
    main()

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

L = list(map(int, input().strip().split()))
dist=0
while True:
    if X-dist not in L:
        ans=X-dist
        break
    elif X+dist not in L:
        ans=X+dist
        break
    dist+=1
print(ans)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
cnt = 0
sop = sorted(p)
for i in range (len(sop)):
    sop[i] -= x
while True:
    if -cnt not in sop:
        print(x-cnt)
        break
    elif cnt not in sop:
        print(x+cnt)
        break
    else:
        cnt +=1

Solution (Python):
x,n=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
for i in range(100):
    if not x-i in p:
        print(x-i)
        exit(0)
    if not x+i in p:
        print(x+i)
        exit(0)

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

i=0

while True:
    if X-i in A and X+i in A:
        i+=1
    elif X-i in A:
        print(X+i)
        exit()
    else:
        print(X-i)
        exit()

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

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
t=0
while t<=100:
    if x-t not in p:
        print(x-t)
        exit()
    if x+t not in p:
        print(x+t)
        exit()
    t += 1

Solution (Python):
target = input().split()
target = [int(i) for i in target]
try:
  arr = input().split()
  arr = [int(i) for i in arr]
except:
  arr = []

if len(arr)==0:
  print(target[0])
else:
  i=0
  while(1):
    if target[0]-i in arr and target[0]+i in arr:
      i+=1
    elif target[0]-i not in arr:
      print(target[0]-i)
      break
    elif target[0]+i not in arr:
      print(target[0]+i)
      break

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")



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

    ans = X
    tmp = INF
    for n in range(X, 102):
        if abs(X-n) < tmp and not n in p:
            ans = n
            tmp = abs(X-n)
            break
    for n in reversed(range(-1, X)):
        if abs(X-n) <= tmp and not n in p:
            ans = n
            break
    
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
x,n = map(int,input().split())
p_L = list(map(int,input().split()))
p_L = set(p_L)
sa = 101
for i in range(0,200):
    if i not in p_L:
        if sa > min(sa,abs(i-x)):
            sa = abs(x-i)
            ans = i

print(ans)

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

sa = float("inf")
ans = 0
for i in range(105, -5, -1):
    if sa >= abs(x - i) and (i not in p):
        ans = i
        sa = abs(x - i)
print(ans)

Solution (Python):
X,N = list(map(int, input().split()))
if(N==0):
  print(X)
else:
  p = list(map(int, input().split()))
  now1 = X
  now2 = X
  while(1):
    if(now1 not in p):
      print(now1)
      break
    elif(now2 not in p):
      print(now2)
      break
    now1 -= 1
    now2 += 1

Solution (Python):
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math


MOD = 10 ** 9 + 7



x, n = map(int, input().split())
A = set(map(int, input().split()))
P = [i for i in range(102) if i not in A]
min_dif = (-1, float("inf"))
for i in range(len(P)):
    if abs(x-P[i]) < min_dif[1]:
        min_dif = (P[i], abs(x-P[i]))

print(min_dif[0])

Solution (Python):
X, N = [int(i) for i in input().split()]
if N==0:
    print(X)
    quit()
P = list(set(range(-10, 110)) - {int(i) for i in input().split()})



P.sort()

D = [abs(P[i]-X) for i in range(len(P))]

print(P[D.index(min(D))])

Solution (Python):

def main():
  x, n = map(int, input().split())
  arr = set(map(int, input().split()))

  i = 0
  while True:
    if x - i not in arr:
      print(x - i)
      return

    if x + i not in arr:
      print(x + i)
      return

    i += 1



main()

Solution (Python):
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq

x, n = map(int, sys.stdin.readline().split())

p = list(map(int, sys.stdin.readline().split()))

r = []
for i in range(1000):
    r.append(-500+i)

for i in range(n):
    r.remove(p[i])
    
ans = []
q = 10 ** 8
for i in range(len(r)):
    if abs(r[i] - x) < q:
        q = abs(r[i] - x)

for i in range(len(r)):
    if q == abs(r[i] - x):
        ans.append(r[i])


    
print(min(ans))

Solution (Python):
target_x, n = map(int,input().split())
p_ls = list(map(int, input().split()))
p_ls.sort()

min_diff = float('inf')
ans_maybe = []
for i in range(102):
    if min_diff > abs(target_x-i):
        if i not in p_ls:
            min_diff = abs(target_x-i)
            ans_maybe = []
            ans_maybe.append(i)
    elif min_diff == abs(target_x-i):
        if i not in p_ls:
            ans_maybe.append(i)
print(min(ans_maybe))

Solution (Python):
x,n = map(int,input().split())
if n:
    p = list(map(int,input().split()))
else:
    p = []
p = set(p)
pp = set([item for item in range(0,105) if item not in p])
v = 3000
ans = -1
for item in pp:
    if v>abs(x-item):
        v = abs(x-item)
        ans = item
print(ans)

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

t=100000
ans=0
for i in range(102):
    if i in p:
        continue
    elif t>abs(i-x):
        t=abs(i-x)
        ans=i

print(ans)

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

minSa = 500
ans = -501

for i in range(-500, 501):
    if i in p:
        continue
    else:
        sa = abs(i - x)
        if sa < minSa:
            minSa = sa
            ans = i

print(ans)

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

    for i in range(-1,102):
        if(i not in p):
            e = abs(i - X)
            if e < ans:
                ans = e
                ans1 = i
    print(ans1)
else:
    print(X)

Solution (Python):
x, n = map(int, input().split())
banned = set()
if n:
    banned |= set(map(int, input().split()))
l = x
r = x
while l in banned and r in banned:
    l -= 1
    r += 1

if l not in banned:
    print(l)
elif r not in banned:
    print(r)

Solution (Python):
import bisect
x,n = map(int,input().split())
p = list(map(int,input().split()))
lis = []
for i in range(110,-50,-1):
    if i not in p:
        lis.append(i)
m = 10000
ans = 0
for i in lis:
    if abs(x-i)<=m:
        m = abs(x-i)
        ans = i

print(ans)

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

p_set = set(p_list)
for i in range(100):
    test_x = x - i;
    if test_x not in p_set:
        print(test_x)
        break
    test_x = x + i;
    if test_x not in p_set:
        print(test_x)
        break

Solution (Python):
X,N = list(map(int, input().split()))
try:
  n = list(map(int, input().split()))
except:
  n = []

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

Solution (Python):
x,n=map(int,input().split())
l=list(map(int,input().split()))
num=[]
for i in range(-100,102):
    num.append(i)
for i in l:
    num.remove(i)
dif=101
ans=[]
for i in num:
    if dif>abs(i-x):
        dif=abs(i-x)
        ans=[i]
    elif dif==abs(i-x):
        ans.append(i)
print(min(ans))

Solution (Python):

import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

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

sub = [False] * 210
for i in range(n):
    sub[p[i] + 105] = True
sub[x] = True

ans = mod
nn = 0
for i in range(210):
    if not sub[i]:
        if ans > abs((i - 105) - x):
            nn = i - 105
            ans = abs((i - 105) - x)
            

print(nn)

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

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

if x not in plist:
    print(x)
    exit()
i = +1
while True:
    if x-i not in plist:
        print(x-i)
        exit()
    if x+i not in plist:
        print(x+i)
        exit()
    i += 1

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

distance = 0
while True:
    if X -distance not in plist:
        print(X-distance)
        break
    if X + distance not in plist:
        print(X+distance)
        break
    distance += 1

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

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

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

Solution (Python):
import sys

X, N = map(int, sys.stdin.readline().strip().split())
P = list(map(int, sys.stdin.readline().strip().split()))

i = 0
while True:
    ans = X - i
    if ans not in P:
        break

    ans = X + i
    if ans not in P:
        break

    i += 1

print(ans)

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

print(ans)

Solution (Python):

import sys
import collections
input = sys.stdin.readline

a,b= map(int,input().split())
if b==0:
    print(a)
    sys.exit()
A = list(map(int,input().split()))
for i in range(100):
    if a - i not in A:
        print(a-i)
        sys.exit()
    if a + i not in A:
        print(a+i)
        sys.exit()

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

def resolve():
    x,n=pin()
    p=set(pin())
    dis=100000
    ans=-1
    for i in range(-1,101+1):
        if i in p:continue

        if abs(x-i)<dis:
            ans=i
            dis=abs(x-i)
    print(ans)

resolve()

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

table = [True] * 102
for p in ps:
    table[p] = False
if table[x]:
    print(x)
    exit()

i = 1
while True:
    if table[x - i]:
        print(x - i)
        break
    if table[x + i]:
        print(x + i)
        break
    i += 1

Solution (Python):
def main():
    x,n = tuple([int(t)for t in input().split()])

    p = tuple([int(t)for t in input().split()])

    nums = set(range(0,102))

    for p_i in p:
        nums.discard(p_i)

    dist = 10**8
    ans = -1

    for i in nums:
        if dist>abs(x-i):
            dist = abs(x-i)
            ans = i

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

Solution (Python):
x,n = [int(i) for i in input().split()]
a = []
if n != 0:
    a = [int(i) for i in input().split()]
d = {}
dis = 0
for i in a:
    d[i] = 1
for i in range(102):
    if i in d:
        continue
    if abs(x - dis) > abs(x-i):
        dis = i
print(dis)

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

diff = {} 
for num in range(-101, 202):
    if num not in p:
        if abs(X-num) not in diff.keys():
            diff[abs(X-num)] = []
        diff[abs(X-num)].append(num)

diff = list(diff.items())
diff.sort()
ans = min(diff[0][1])
print(ans)

Solution (Python):
import sys

X, N = map(int, input().split())
P = list(map(int, sys.stdin.readline().rsplit()))

m = 1000
for i in range(102):
    if i in P:
        continue
    if abs(X - i) < m:
        m = abs(X - i)
        res = i
    else:
        break

print(res)

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

if n==0:
    print(x)
else:
    minp = min(min(p),x)
    maxp = max(max(p),x)
    
    mi=200
    ans=0
    for i in range(minp-1,maxp+2):
        if i not in p and abs(i-x)<mi:
                mi=abs(i-x)
                ans=i
    print(ans)

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


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

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

i = 0
if N == 0:
    print(X)
else:
    while True:
        minus_value = X - i
        plus_value = X + i
        if minus_value not in p:
            if plus_value not in p:
                print(minus_value)
                break
            else:
                print(minus_value)
                break
        else:
            if plus_value not in p:
                print(plus_value)
                break
            else:
                i += 1

Solution (Python):
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

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

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

Solution (Python):
[x,n]=list(map(int,input().split()))
plist=list(map(int,input().split()))
nums=[]
for i in range(102):
    if i not in plist:
        nums.append(i)

for i in range(1000):
    if x-i in nums:
        ans=x-i
        break
    if x+i in nums:
        ans=x+i
        break

print(ans)

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


if N > 0:
    p = list(map(int,input().split()))
    
    for i in range(1000):
        if X-i not in p:
            print(X-i)
            break
        elif X+i not in p:
            print(X+i)
            break
    
    
    
else:
    input()
    print(X)

Solution (Python):
def main():
    X, N = [int(x) for x in input().split()]
    if N == 0:
        print(X)
        return

    PS = [int(x) for x in input().split()]
    for i in range(0, 100):
        for sign in (-1, +1):
            v = X + i * sign
            if v not in PS:
                print(v)
                return


main()

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

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