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

if N == 0:
    print(X)
    exit()
ans = None
plus = 0
while True:
    if X - plus not in P:
        ans = X-plus
        break
    elif X + plus not in P:
        ans = X + plus
        break
    plus += 1

print(ans)

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

for j in range(100):
    a1=x-j
    a2=x+j
    if a1 not in p:
        print(a1)
        exit()
    if a2 not in p:
        print(a2)
        exit()

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

Y=X
while X in P and Y in P:
        X+=1
        Y-=1

if  Y not in P:
    print(Y)
else:
    print(X)

Solution (Python):
num=[i for i in range(-100,201)]
X,N=list(map(int,input().split()))
p=list(map(int,input().split()))
for i in p:
    if i in num:
        num.remove(i)
min=[1000,0]
for i in num:
    if abs(i-X)<min[0]:
        min=[abs(i-X),i]
print(min[1])

Solution (Python):
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  
from heapq import heappush, heappop
import bisect


"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) 
A = [int(input()) for _ in range(N)] 
lst = [list(map(int,input().split())) for i in range(M)] 
"""


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

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

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

  
current = 10000 
ans = 0
for i in range(0, 102):
  if i in P:
    continue
  else:
    var = abs(i - X)
    if current > var:
      current = var
      ans = i
    
    
print(ans)

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

for i in range(x,x+200):
    if i not in a:
        ans1=i
        break
for i in range(x,x-200,-1):
    if i not in a:
        ans2=i
        break
if abs(ans1-x)>=abs(ans2-x):
    print(ans2)
else:
    print(ans1)

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

INF = float("inf")


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

    d = defaultdict(int)
    p = list(map(int,input().split()))
    for i in range(N):
        d[p[i]] += 1
    mmin = 0
    Mmin = 101
    for i in range(X):
        if d[i] == 0:
            mmin = i
    for i in range(X,102):
        if d[i] == 0:
            Mmin = i
            break
    a = X-mmin
    b = Mmin-X
    if a == b or a < b:
        print(mmin)
    else:
        print(Mmin)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
diff = 101 - x
ans = 101
for i in range(-1, 101):
    if i in p:
        continue
    if abs(i - x) < diff:
        diff = abs(i - x)
        ans = i
    elif abs(i - x) == diff:
        ans = min(ans, i)
print(ans)

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

lst = [(abs(i - X), i) for i in range(0, 102)]
lst.sort()

for a, b in lst:
    if b not in P:
        print(b)
        exit()

Solution (Python):
x, n = map(int, input().split())
p = set(map(int, input().split()))
if n != 0:
    p_all = set([i for i in range(min(p) - 1, max(p) + 2)])
    q = list(p_all - p)
    q.sort(reverse=True)
    d = float('inf')
    for i in q:
        tmp = abs(i - x)
        if tmp <= d:
            d = tmp
            ans = i
else:
    ans = x
print(ans)

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
l, r = 0, 0
for i in range(0, X+1):
    if not i in P:
        l = i
for i in range(101, X, -1):
    if not i in P:
        r = i
if abs(X-l) <= abs(X-r):
    print(l)
else:
    print(r)

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

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

for i in range(100 + 2):
    if not(i in p):
        if abs(x - i) < abs(x - min_num):
            min_num = i

print(min_num)

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

Solution (Python):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



X, N = input_int()

P=many_int()

from collections import defaultdict
dicts = defaultdict(bool)
for p in P:
    dicts[p] = True



def serach(X, dicts):
    for i in range(100):
        min_val =X-i
        max_val = X+i
        
        if (not dicts[min_val]):
            return min_val
        if (not dicts[max_val]):
            return max_val
            



if X not in P:
    print(X)
else:
    print(serach(X, dicts))

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

arr.sort()

if x not in arr:
    print(x)
    sys.exit()

ans = 1000
cnt = 0
while True:
    lower = x - cnt
    upper = x + cnt
    if lower not in arr:
        ans = min(ans, lower)
    if upper not in arr:
        ans = min(ans, upper)
    if ans != 1000:
        break
    cnt += 1

print(ans)

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

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

    mi = 200
    for i in range(102):
        if not i in p:
            d1 = abs(x-i)
            if d1<mi:
                ans = i
                mi = min(d1,mi)
    print(ans)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
for i in range(150):
    if p.count(x + i) == 0 and p.count(x - i) == 0:
        print(min(x + i, x - i))
        break
    elif p.count(x + i) == 0:
        print(x + i)
        break
    elif p.count(x - i) == 0:
        print(x - i)
        break
    else:
        continue

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

Solution (Python):
def main(X, N, P):
    st = set(P)
    if N == 0:
        print(X)
    else:
        n = 0
        while True:
            if X - n not in st:
                print(X - n)
                exit()
            elif X + n not in st:
                print(X + n)
                exit()
            else:
                n += 1

if __name__ == '__main__':
    X, N = list(map(int, input().split()))
    P = list(map(int, input().split()))
    main(X, N, P)

Solution (Python):



X, N = map(int, input().split())
if N != 0:
    P = list(map(int, input().split()))
    
    
    
    
    
    
    
    
    
    
    
    
    
    for diff in range(0,102):
        if X-diff not in P:
            print(X-diff)
            break
        elif X+diff not in P:
            print(X+diff)
            break
else:
    print(X)

Solution (Python):
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int,input().split()))
if x not in p:
  print(x)
  exit()
p.sort()
for i in range(n):
  if p[i] == x:
    d = i
j = 1
while True:
  if d-j < 0:
    print(x-j)
    exit()
  if p[d-j] != x-j:
    print(x-j)
    exit()
  if d+j > n-1:
    print(x+j)
    exit()
  if p[d+j] != x+j:
    print(x+j)
    exit()
  j += 1

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
if x not in p:
    print(x)
else:
    for i in range(1, n+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())
N = list(map(int, input().split()))

for i in range(101):
    if not(x-i in N):
        ans=x-i
        break
    if not(x+i in N):
        ans=x+i
        break

print(ans)

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

for i in range(100):
    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:
  print(X)
else:
  P = list(map(int, input().split()))
  c_list = []
  for p in P:
    if p-1 not in P:
      c_list.append(p-1)
    if p+1 not in P:
      c_list.append(p+1)
  c_list.sort()
  ans = c_list[0]
  for c in c_list:
    if abs(c-X) < abs(ans-X):
      ans = c
  print(ans)

Solution (Python):
X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  p.sort()
  
  for i in range(52):
    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:
    input()
    print(X)
    exit(0)
xn=list(map(int,input().split()))

a=[(abs(x-X),x) for x in xn]

for d in range(0, 100):
    a1=d+X
    a2=-d+X
    if a2 not in xn:
        print(a2)
        exit(0)
    elif a1 not in xn:
        print(a1)
        exit(0)

Solution (Python):
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
A=set(map(int,input().split()))
for i in range(100):
  if x+i not in A:
    a=x+i
    break
for i in range(100):
  if x-i not in A:
    b=x-i
    break

if abs(a-x)==abs(x-b):
  print(b)
elif abs(a-x)>abs(x-b):
  print(b)
else:
  print(a)

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(200):
    for sgn in [-1, 1]:
        cand = X + sgn * i
        if cand not in p:
            print(cand)
            exit()

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
t=[]
a=x-1
b=x+1
if x not in p:
  t.append(x)

while t==[]:
  if a not in p:
    t.append(a)
  if b not in p:
    t.append(b)
  a-=1
  b+=1
print(min(t))

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

for j in range(100):
    a1=x-j
    a2=x+j
    if a1 not in p:
        print(a1)
        exit()
    if a2 not in p:
        print(a2)
        exit()

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

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

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

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

for i in range(101):
  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=list(map(int,input().split()))

a=[0]*102
for i in range(n):
    a[p[i]]+=1
l=x
s=x
while True:
    if a[s]==0:
        ans=s
        break
    s-=1
    if a[l]==0:
        ans=l
        break
    l+=1
    
print(ans)

Solution (Python):
X,N = map(int,input().split())
P = set(list(map(int,input().split())))
reverseP = []
for i in range(102):
    if i not in P:
        reverseP.append(i)
ans = 0
diff = float("INF")
for a in reverseP:
    if abs(a-X)<diff:
        ans = a
        diff = abs(a-X)
print(ans)

Solution (Python):
x,n = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for i in l:
    if i not in d:
        d[i] = 1
left, right = x,x
while left in d and right in d:
    left -= 1
    right += 1
print(left if left not in d else right)

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

if N!=0:

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

    B = X
    S = X

    while True:
        
        if P.count(S) == 0:
            print(S)
            break
        elif P.count(B) == 0:
            print(B)
            break
        S -= 1
        B += 1

else:
    print(X)

Solution (Python):
def main():
  x, n = map(int, input().split())
  if n:
    p = list(map(int, input().split()))
    i = 0
    while True:
      if not x-i in p:
        print(x-i)
        break
      elif not x+i in p:
        print(x+i)
        break
      i += 1
  else:
    print(x)
      
if __name__ == "__main__":
  main()

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

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    
    left = p
    for i in range(x, -100, -1):
        if i not in p:
            left = i
            break
    
    right = p
    for i in range(x, 110):
        if i not in p:
            right = i
            break

    leftabs = abs(x - left)
    rightabs = abs(right - x)

    if leftabs == rightabs:
        print(left)
    elif leftabs > rightabs:
        print(right)
    else:
        print(left)

Solution (Python):

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

Solution (Python):
X,N=map(int,input().split())
if N!=0:
  P=list(map(int,input().split()))
else:
  P=[]
if X not in P:
  print(X);exit()

r=1000
ans=0
for i in range(200,-200,-1):
  if i not in P:
    if r>=abs(i-X):
      r=abs(i-X)
      ans=i
print(ans)

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

p_s.sort()
ans = 0
tmp_diff = float('inf')

for num in range(-300,301):
    if(num not in p_s):
        diff = abs(X - num)
        if (diff < tmp_diff):
            ans = num
            tmp_diff = diff
            
print(ans)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint


INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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

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

def RI():
    return list(map(int,input().split()))

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

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

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

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

x,n = MI()
p = RI()

m = INF
ans = INF
for i in range(-102,102):
    if i in p:
        pass
    else:
        sa = abs( x - i )
        if sa<m:
            ans = i
            m = sa
        elif sa==m:
            ans = min(i,ans)
        else:
            pass
print(ans)

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

Solution (Python):
x,y=map(int,input().split())
if y==0:
    print(x)
    exit(0)
s=list(map(int,input().split()))
res=100
mn=110
for n in range( 110):
    if n not in s:
        v=abs(x-n)
        if v<res:
            res=v
            mn=n

print(mn)

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

mi = 1000
ans = -1
for i in range(-1, 105):
    if i not in P:
        if mi > abs(X - i):
            mi = abs(X - i)
            ans = i
print(ans)

Solution (Python):
import sys
X,N =  map(int,input().split())
if N == 0:
  print(X)
  sys.exit()
p = list( map(int,input().split()))
gans = X
gx = X
lans = X
lx = X
for i in range(100+1):
  if gx not in p:
    gans = gx
    break
  else:
    gx += 1
for i in range(100+1):
  if lx not in p:
    lans = lx
    break
  else:
    lx -= 1

if abs(X-gans) < abs(X-lans):
  print(gans)
else:  
  print(lans)

Solution (Python):
X, N = map(int, input().split())
pn = list(map(int, input().split()))
diff = 100
ans = X
if pn:
    for i in range(min(pn)-1, max(pn)+2):
        if i in pn:
            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)
else:
    p = list(map(int, input().split()))
    if x not in p:
        print(x)
    else:
        i = 1
        while True:
            if x-i not in p:
                print(x-i)
                break
            elif x+i not in p:
                print(x+i)
                break
            i += 1

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7






X, N = getNM()
P = sorted(getList())
P = set(P)

for i in range(500):
    opt1 = X + i
    ans = []
    if not opt1 in P:
        ans.append(opt1)
    opt2 = X - i
    if not opt2 in P:
        ans.append(opt2)
    if len(ans) > 0:
        print(min(ans))
        break

Solution (Python):
x,n=map(int,input().split())
s=input()
if n!=0:
  l=list(map(int,s.split()))
  cnt=0
  ans=0
  while True:
    if x-cnt in l:
      if x+cnt in l:
        cnt=cnt+1
      else:
        ans=x+cnt
        break
    else:
      ans=x-cnt
      break
  print(ans)
else:
  print(x)

Solution (Python):



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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    X, N = MI()
    P = LI()

    ans = X
    if P == []:
        print(ans)
        return

    
    
    
    

    mn = INF
    for i in range(X-110, X+110):
        
        if i not in P:
            if mn > abs(X - i):
                mn = abs(X - i)
                ans = i
            
    print(ans)

if __name__ == '__main__':
    solve()

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

for i in range(100):
    tmp = x
    if tmp - i not in p:
        print(tmp-i)
        break
    elif tmp + i not in p:
        print(tmp+i)
        break

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

Solution (Python):







from math import *


def _in():
    return [int(x) for x in input().split(' ')]


def main():
    x, n = _in()
    if(n == 0):
        print(x)
        return
    arr = _in()

    diff = 0
    while(True):
        l = x - diff
        if not(l in arr):
            print(l)
            return
        r = x + diff
        if not(r in arr):
            print(r)
            return
        diff = diff + 1


if __name__ == "__main__":
    tt = 1
    
    for _ in range(tt):
        main()

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

    for p in ps:
        n[p+100]+=1
    if n[x+100]==0:
        print(x)
    else:
        ans=0
        for i in range(1,200):
            if n[x-i+100]==0:
                ans=x-i
                break
            elif n[x+i+100]==0:
                ans=x+i
                break
        print(ans)

Solution (Python):

"""
Created on Sun Jun 14 21:08:40 2020

@author: NEC-PCuser
"""

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

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

print(ans)

Solution (Python):
def resolve():
    x, n = map(int, input().split())
    if n ==0:
        print(x)
    else:
        p = list(map(int, input().split()))
        ans = 0
        diff = 10**5
        for i in range(-1, 102):
            if i in p:
                continue
            else:
                if diff > abs(x-i):
                    ans = i
                    diff = abs(x-i)
        print(ans)
resolve()

Solution (Python):
X,N=input().split()
P=list(map(int, input().split()))
X=int(X)
N=int(N)
a1=X
a2=X
while (a1 in P)and(a2 in P):
    a1-=1
    a2+=1
if a1 in P:
    print(a2)
elif a2 in P:
    print(a1)
else:
    print(a1)

Solution (Python):
import sys


x, n = map(int, input().split())
p = {int(i): True for i in input().split()}

i = 0

while True:
    try:
        if p[x-i]:
            pass
            
    except KeyError:
        print(x-i)
        sys.exit()
    
    try:
        if p[x+i]:
            pass
    except KeyError:
        print(x+i)
        sys.exit()
    
    i += 1

Solution (Python):
from sys import exit
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
ban = set(map(int, input().split()))
diff = 200
for i in range(102):
  if i in ban:
    continue
  if abs(x - i) < diff:
    diff = abs(x - i)
    ans = i
print(ans)

Solution (Python):
"""
~~ Author : Bhaskar
~~ Dated : 07~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi,log
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    x,n = map(int,sys.stdin.readline().split())
    a = list(map(int,sys.stdin.readline().split()))
    if n == 0:
        print(x)
    else:
        a.sort()
        ans = []
        for i in range(150):
            if i not in a:
                ans.append(i)
        ans.sort(key = lambda i : abs(x-i))
        print(ans[0])




if __name__ == "__main__":
    
    
    
    
    solve()

Solution (Python):
x,n=map(int,input().split())
s=sorted(list(map(int, input().split())))
a=x
b=x
if n==0:
    print(x)
    exit()
for i in range(n+100):
    if not (a in s):
        print(a)
        exit()
    if not (b in s):
        print(b)
        exit()
    a-=1
    b+=1

Solution (Python):
X,N = map(int,input().split())
p = list(map(int,input().split()))
a,b = [],[]
cnt = 0
for i in range(0,100):
    if X + cnt not in p:
        a.append(X + cnt)
    if X - cnt not in p:
        b.append(X - cnt)
    cnt += 1
A = a[0]-X
B = X-b[0]
if A < B:
    print(a[0])
else:
    print(b[0])

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

m = 1e9
ans = None
for i in range(101,-2,-1):
  if i in l:
    continue
  if abs(x-i) <= m:
    m = abs(x-i)
    ans = i
print(ans)

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

p = set(_p)

for i in range(100):
  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 = list(map(int,input().split()))
for i in range(51):
    if not x-i in p:
        print(x-i)
        break
    elif not x+i in p:
        print(x+i)
        break

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

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

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

Solution (Python):
x,n=map(int,input().split())
p=sorted(list(map(int,input().split())))
if n==0:
    print(x)
    exit()
q=[0]*(p[-1]+2)
for i in range(n):
    q[p[i]]=1
ans=(1000000,-1)
for i in range(p[-1]+2):
    if q[i]==0:
        if ans[0]>abs(i-x):
            ans=(abs(i-x),i)
print(ans[1])

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

chk=[0 for _ in range(109)]

for i in range(N):
    p=P[i]
    chk[p]=1
ans=10**7
res=-1
for x in range(-1,109):
    if x==-1:
        val=abs(X-x)
    else:
        if chk[x]==1:
            continue
        val=abs(X-x)
    if val<ans:
        ans=val
        res=x

print(res)

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

for i in range(101):
    if x-i not in pli:
        print(x-i)
        break
    if x+i not in pli:
        print(x+i)
        break

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

val=0
while True:
    Xa = X - val
    Xb = X + val

    if Xa in p:
        pass
    else:
        print(Xa)
        exit()

    if Xb in p:
        pass
    else:
        print(Xb)
        exit()

    val+=1

Solution (Python):
def main():
    x,n = map(int,input().split())
    p_s = list(map(int,input().split()))
    for i in range(101):
        

        if (x-i) not in p_s:

            answer = x - i
            break
        if (x + i) not in p_s:
            
            answer = x + i
            break
    print(answer)



if __name__ == '__main__':
    main()

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

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

res = -1
sa = 1000000
for i in range(-2001,2001):
    if i not in p:
        if abs(i-X) < sa:
            res = i
            sa = abs(i-X)

print(res)

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

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

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

Solution (Python):
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    P = list(map(int, input().split()))
    P = set(P)
    ans = 0
    i = 0
    while ans == 0:
        Xa = X-i
        Xb = X+i
        if Xa not in P:
            ans = Xa
            break
        if Xb not in P:
            ans = Xb
        i += 1
    print(ans)

Solution (Python):
import itertools
import copy
from collections import deque
import heapq
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int,input().split()))
check = {key:0 for key in p}
mi = copy.deepcopy(x)
ma = copy.deepcopy(x)
while True:
    if not mi in check:
        print(mi)
        exit()
    if not ma in check:
        print(ma)
        exit()
    mi -= 1
    ma += 1

Solution (Python):
def solve():
    ret = -1
    diff = float('inf')
    for i in range(102):
        if i in p:
            continue
        if abs(X - i) < diff:
            ret = i
            diff = abs(X - i)
    print(ret)

if __name__ == "__main__":
    X, N = map(int, input().split())
    p = set((map(int, input().split())))
    solve()

Solution (Python):
import sys

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

tmp1 = 201
tmp2 = 201

for i in range(0,100):
  if X-i not in p:
    tmp1 = X-i
  elif X+i not in p:
    tmp2 = X+i
  if tmp1 != 201 or tmp2 != 201:
    print(min(tmp1,tmp2))
    sys.exit()

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
a = [i for i in range(-1, 103)]
for P in p:
    a.remove(P)

ans = 101
d = 10000
for A in a:
    if d > abs(A-X):
        ans = A
        d = abs(A-X)


print(ans)