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

from __future__ import division, print_function

import os
import sys
import itertools
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    x, n = map(int, input().split())
    p = {int(pi) for pi in input().split()}

    for i in itertools.count():
        if (x - i) not in p:
            print(x - i)
            break
        if (x + i) not in p:
            print(x + i)
            break




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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

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



if __name__ == "__main__":
    main()

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
q = []
for i in range(102):
	if i not in p:
		q.append(i)
q.sort(key=lambda z: abs(z-x))
if len(q) < 2:
	print(q[0])
else:
	if abs(q[0] - x) == abs(q[1] - x):
		print(min(q[0], q[1]))
	else:
		print(q[0])

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

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

a = [0 for _ in range(102)]

tmp = 10**5
res = 0

for i in range(N):
    a[P[i]] += 1

for i in range(102):
    if a[i]:
        continue
    if tmp > abs(i - X):
        tmp = abs(i - X)
        res = i
print(res)

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    X, N = map(int, rl().split())
    p = set(map(int, rl().split()))
    
    ans = -1
    d_min = 1000
    for i in range(102):
        if i not in p:
            if abs(X - i) < d_min:
                d_min = abs(X - i)
                ans = i
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
s=1000
ret=-1000
x,n=map(int,input().split())
if n==0:
	print(x)
	exit()
p=list(map(int,input().split()))
p=set(p)
for i in range(-101,202):
	if i not in p:
		if s>abs(x-i):
			s=abs(x-i)
			ret=i
print(ret)

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]




X, N = mi()
A = li()

flag = [0] * (205)

for num in A:
    flag[num] = 1

if not flag[X]:
    print(X)
    exit()

i = 1
while True:
    if not flag[X - i]:
        print(X-i)
        exit()
    elif not flag[X + i]:
        print(X+i)
        exit()
    i += 1

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

for i in range(100):
    if x-i not in p:
        print(x-i)
        sys.exit()
    if x+i not in p:
        print(x+i)
        sys.exit()

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

diff = 100
for x in range(-100, 201):
    tmp = abs(X - x)
    if x in P:
        continue
    else:
        if tmp < diff:
            ans = x
            diff = tmp

print (ans)

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

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

for i in range(200):
  MIN = X-i
  MAX = X+i
  if MIN not in pset:
    print(MIN)
    exit()
  elif MAX not in pset:
    print(MAX)
    exit()

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

    d, v = X, 0
    for i in range(102):
        if i in P:
            continue
        if abs(i - X) < d:
            d = abs(i - X)
            v = i
    return v


print(main())

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(100):
  if X-i in p:
    pass
  else:
    print(X-i)
    exit()
    
  if X+i in p:
    pass
  else:
    print(X+i)
    exit()

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

  check=x
  if (p.count(x)==0):
      print(check)
  else:
      check1=check
      check2=check
      for i in range(100):
          check1=check1-1
          if (p.count(check1)==0):
              print(check1)
              break
          check2=check2+1
          if (p.count(check2)==0):
              print(check2)
              break

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    X, N = LI()
    P = LI()
    s = set(P)
    diff = inf
    ans_x = -1
    for x in range(-101, 300):
        if x in s:
            continue
        if abs(x-X) < diff:
            diff = abs(x-X)
            ans_x = x
    print(ans_x)





main()

Solution (Python):
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(X, N, Ps):
    Ps = set(Ps)
    d = 0
    while True:
        if X - d not in Ps:
            return X - d
        if X + d not in Ps:
            return X + d
        d += 1


if __name__ == "__main__":
    X, N = tuple(map(int, input().split(" ")))
    Ps = []
    if N > 0:
        Ps = list(map(int, input().split(" ")))
    print(solve(X, N, Ps))

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

flag=False
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, = map(int, input().split())

    B = [0] * (400 + 1)
    for i in P:
        B[i] += 1

    d = 0
    while True:
        if not B[X - d]:
            print(X - d)
            return

        if not B[X + d]:
            print(X + d)
            return

        d += 1


if __name__ == '__main__':
    main()

Solution (Python):
x, n = map(int, input().split())
p = set(list(map(int, input().split())))
a = set(list(range(102)))
a = list(a - p)
a.sort()

tmp = 10 ** 10
for i in a:
    if tmp > abs(x - i):
        tmp = abs(x - i)
        ans = i
print(ans)

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

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

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

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

ans = 10000
for r in range(-1, 105):
    if r in p:
        continue
    ans = min(ans, r, key=lambda y: abs(x-y))

print(ans)

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

pset=set(map(int,input().split()))
for i in range(1000):
  if not X-i in pset:
    print(X-i)
    sys.exit(0)
  if not X+i in pset:
    print(X+i)
    sys.exit(0)

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    X, N = map(int, input().split())
    P = [int(p) for p in input().split()]
    Num = [True] * 102
    for p in P: Num[p] = False
    minDiff = 10000000000
    ans = 0
    for i, t in enumerate(Num):
        if t == True and abs(X - i) < minDiff:
            ans = i
            minDiff = abs(X - i)
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

X, N = rl()
P = rl()

h = {}
for p in P:
	h[p] = 1

for i in range(105):
	if X-i not in h:
		print(X-i)
		exit()
	if X+i not in h:
		print(X+i)
		exit()

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

for i in range(100):
    x_m = x-i
    if not x_m in p:
        print(x_m)
        exit()
    x_p = x+i
    if not x_p in p:
        print(x_p)
        exit()

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

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

ans=-200000

for i in range(-200,200):
    if not i in p:
        if abs(x-ans)>abs(x-i):
            ans=i

print(ans)

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

dist = []
for i in range(102):
    if i in p:
        dist.append((i, INF))
    else:
        dist.append((i, abs(x - i)))

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

Solution (Python):
def examA():
    X = LI()
    for i in range(len(X)):
        if X[i]==0:
            ans = i+1
    print(ans)
    return

def examB():
    X, Y = LI()
    ans = "No"
    for i in range(X+1):
        if i*2+(X-i)*4==Y:
            ans = "Yes"
    print(ans)
    return

def examC():
    X, N = LI()
    P = LI()
    P = set(P)
    cur = inf
    ans = -1
    for i in range(-1,102):
        if i in P:
            continue
        now = abs(i-X)
        if now<cur:
            ans = i
            cur = now
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

ans = 0
res = 10**9
for i in range(x-100, x+101):
    if i in p:
        continue
    diff = abs(x-i)
    if diff < res:
        ans = i
        res = diff
print(ans)

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

cand1 = x
while cand1 in p:
    cand1 -= 1

cand2 = x
while cand2 in p:
    cand2 += 1

if abs(cand1 - x) <= abs(cand2 - x):
    ans = cand1
else:
    ans = cand2

print(ans)

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

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

res = -100
for r in range(-100,200):
    if r not in pl:
        if abs(x-r)<abs(x-res):
            res = r
print(res)

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

diff = 1e9
ans = -1
for i in range(0,102):
    if i not in arr:
        d = abs(x-i)
        if d < diff:
            diff = d
            ans = i

print(ans)

Solution (Python):
x, n = [int(_) for _ in input().split()]
p = set([int(_) for _ in input().split()])
cand = []
for i in range(102):
    if i in p:
        continue
    cand += [(abs(i - x), i)]
cand.sort()
print(cand[0][1])

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

for i in range(100):
    if x - i not in p:
        print(x - i)
        exit()

    elif x + i not in p:
        print(x + i)
        exit()

Solution (Python):

import sys


def solve(X: int, N: int, p: "List[int]"):
    for i in range(101):
        if (X - i) not in p:
            print(X-i)
            return
        elif (X + i) not in p:
            print(X+i)
            return

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    N = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(X, N, p)

if __name__ == '__main__':
    main()

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

Solution (Python):
def main():

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

    p = set(p)
    ans = 1
    l = float('inf')
    for i in range(-1, 102):
        if i not in p and abs(i-X) < l:
            l = abs(i-X)
            ans = i
    return ans



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

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
x,n=map(int,input().split())
P=set([int(i) for i in input().split()])
ans=0
for i in range(1,102):
  if i in P:
    continue
  else:
    if abs(i-x)<abs(ans-x):
      ans=i
print(ans)

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

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

ans = 0
d = 10 ** 9

for i in range(-200, 201):
    if i not in p:
        if abs(x - i) < d:
            d = abs(x - i)
            ans = i

print(ans)

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

for i in range(0,100):
    if x-i not in pl:
        print(x-i)
        break
    elif x+i not in pl:
        print(x+i)
        break

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

def main():
    x, N = map(int, input().split())
    P = set(map(int, input().split()))
    d = 0
    while True:
        if x + d in P and x - d in P:
            d += 1
            continue
        else: break
    if x - d in P: print(x + d)
    else: print(x - d)
    

if __name__ == "__main__":
    main()

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

    for i in range(101):
        if x-i not in p:
            print(x-i)
            break
        elif x+i not in p:
            print(x+i)
            break
else:
    print(x)

Solution (Python):
import sys

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

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

best_diff = 10000000
best_a = -2
for a in range(-5, 1000):
	if not a in p:
		diff = abs(x - a)
		if diff < best_diff:
			best_diff = diff
			best_a = a

print(best_a)

Solution (Python):
nii=lambda:map(int,input().split())
lnii=lambda:list(map(int,input().split()))

x,n=nii()
p=lnii()

dist=1000
ans=[]
aa=[]
for i in range(-10,110):
  if i not in p:
    ans.append(abs(x-i))
    aa.append(i)
min_inx=ans.index(min(ans))
print(aa[min_inx])

Solution (Python):
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
a = list(map(int,input().split()))
b = [0 for _ in range(-300,301)]
for y in a:
  b[y+300] = 1
c = []
for i in range(601):
  j = i - 300
  if b[i] == 0:
    c.append([abs(x-j),j])
print(min(c)[1])

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

diff = 10 ** 18
ans = -1
for num in range(-1000, 1000)[::-1]:
    if num in set_:
        continue
    if abs(num - x) <= diff:
        diff = abs(num - x)
        ans = num
print(ans)

Solution (Python):

import sys

X,N,*P = map(int, sys.stdin.buffer.read().split())

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

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

p = set(p)

for i in range(0, 200) :
  if not X - i in p :
    print(X - i)
    break
    
  if not X + i in p :
    print(X + i)
    break

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

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

Solution (Python):


X,N=map(int,input().split())
P=list(map(int,input().split()))
A=[]
for a in range(0,102):
    if not a in P:
        A.append(a)

ans=0
for a in A:
    if abs(X-a) < abs(X-ans):
        ans=a

print(ans)

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

if not x in p:
    print(x)
    exit()
for i in range(1,200):
    if not x-i in p:
        print(x-i)
        exit()
    elif not x+i in p:
        print(x+i)
        exit()

Solution (Python):
X,N=map(int,input().split())
p=set(map(int,input().split()))
t=200
a=1000
for i in range(101,-1,-1):
    if i not in p:
        if abs(i-X)<=t:
            a=i
            t=abs(i-X)
print(a)

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

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

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

Solution (Python):
X, N = map(int, input().split(' '))
if N > 0:
    P = set(map(int, input().split(' ')))
else:
    P = set()

for n in range(102):
    if X - n not in P:
        print(X - n)
        break
    elif X + n not in P:
        print(X + n)
        break

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

X, N = map(int, input().split())
p = list(map(int, input().split()))
s = set(p)
low = X-1000
high = X+1000
d = 10**18

for i in range(low, high+1):
    if i not in s:
        d = min(d, abs(X-i))
    
for i in range(low, high+1):
    if i not in s and abs(X-i)==d:
        print(i)
        exit()

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)

x,n = map(int,stdin.readline().rstrip().split())
p = list(map(int,stdin.readline().rstrip().split()))
p.sort()
mi = 10**10
now = 10**10

for i in range(-1000,1000):
    if i not in p:
        if abs(i-x) < mi:
            mi = abs(i-x)
            now = i

print(now)

Solution (Python):
x, n = map(int, input().split())
p = set([int(i) for i in input().split()])
ans = 1000
for i in range(-100, 200):
    if i in p:
        continue
    if abs(i - x) < abs(ans - x):
        ans = i

print(ans)

Solution (Python):
x, n = map(int, input().split())
a = set(list(map(int, input().split())))
ans_d = 10000
ans = -1
for i in range(-100,1000):
    if abs(x - i) < ans_d and i not in a:
        ans = i
        ans_d = abs(x - i)
print(ans)

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

Solution (Python):


import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

for i in range(0, 10000):
    acc = (X - i, X + i)
    for x_ in acc:
        if x_ not in P:
            print(x_)
            sys.exit()

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

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

B = set(A)
t = 10**15
ans = -1
for i in range(103):
    if not i in B and abs(i-X) < t:
        t = abs(i-X)
        ans = i

print(ans)

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

ans=100
mindif=100000
for i in reversed(range(-200,200)):
    if i in p:
        continue
    if mindif>abs(i-X):
        ans=i
        mindif=abs(i-X)
    elif mindif==abs(i-X):
        ans=min(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):
import sys
readline=sys.stdin.readline

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


x = X
while x in P:
  x -= 1

minX = x

x = X
while x in P:
  x += 1
maxX = x

if abs(minX - X) <= abs(maxX - X):
  print(minX)
else:
  print(maxX)

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

ans = 1000000
ansabs = 1000000
for i in range(0, 102):
  if i in p: continue
  if abs(X - i) < ansabs:
    ansabs = abs(X - i)
    ans = i

print(ans)

Solution (Python):

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x, n = LI()
p = LI()
tmp = 0
while 1:
    if x - tmp not in p:
        print(x-tmp)
        quit()
    elif x + tmp not in p:
        print(x+tmp)
        quit()
    tmp += 1

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

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

if not (X in P):
    print(X)
else:
    ANS=-1
    for i in range(100):
        for to in [X-i,X+i]:
            if not(to in P):
                ANS=to
                break
        if ANS!=-1:
            break
    print(ANS)

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

Solution (Python):
X, N = [int(x) for x in input().split()]
if N:
    P  = [int(x) for x in input().split()]
    P = set(P)
else:
    P = set()
best = (float('inf'), )
for i in range(0, 102):
    if i not in P:
        best = min(best, (abs(i - X), i))
print(best[1])

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

x,n = map(int,readline().split())
lst1 = list(map(int,readline().split()))

ans = []

for i in range(-200,200):
    if i in lst1:continue
    ans.append([abs(x-i),i])

res = 1000000
a2 = 9999999
for i in ans:
    if i[0] < res:
        a2 = i[1]
        res = i[0]
print(a2)

Solution (Python):
x,n=map(int,input().split())
p=[]
if n:
	p=list(map(int,input().split()))
ans=None
mi=float("inf")
for i in range(-300,300):
	if i not in p:
		if mi>abs(x-i):
			mi=abs(x-i)
			ans=i
print(ans)

Solution (Python):
X, N = map(int, input().split())
A = set([int(a) for a in input().split()]) if N else []
mi = 105
mii = -1
for i in range(-1, 110):
    if i in A: continue
    if abs(i - X) < mi:
        mi = abs(i - X)
        mii = i
print(mii)

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

x,n=mp()
p=lmp()
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()))
for i in range(200):
    if X - i not in p:
        print(X - i)
        exit()
    if X + i not in p:
        print(X + i)
        exit()

Solution (Python):

import sys
input = sys.stdin.readline

x, n = map(int, input().split())
p = [int(item) for item in input().split()]
seen = set(p)

ans = None 
diff = 200
for val in range(200, -200, -1):
    if val not in seen:
        if abs(val - x) <= diff:
            ans = val
            diff = abs(val - x)

print(ans)

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

Solution (Python):
def main():
    X, N = map(int, input().split())
    p = set(map(int, input().split()))
    i = 0
    while True:
        if X - i not in p:
            return X - i
        if X + i not in p:
            return X + i
        i += 1
print(main())

Solution (Python):
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    x,n = mi()
    p = li()
    for i in range(100):
        if not x-i in p:
            print(x-i)
            exit()
        elif not x+i in p:
            print(x+i)
            exit()



main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x, n = map(int, input().split())
    P = set(list(map(int, input().split())))
    res = 0
    mi = f_inf
    for i in range(-200, 200):
        if i not in P:
            if abs(x - i) < mi:
                mi = abs(x - i)
                res = i
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
P = set(map(int, input().split()))
t = float("inf")
for i in range(-200, 201):
    if i not in P and abs(i-x) < t:
        t = abs(i-x)
        ans = i
print(ans)

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

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