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())
Ps=list(map(int,input().split()))
numlist=[]
for i in range(102):
    numlist.append(i)
for p in Ps:
    numlist.remove(p)
import bisect
a=bisect.bisect_left(numlist,x)
b=a-1
if abs(numlist[a]-x)>=abs(numlist[b]-x):
    print(numlist[b])
else:
    print(numlist[a])

Solution (Python):
X, N = map(int, input().split())
if N ==0:
  print(X)
else:
  List = list(map(int, input().split()))
  res = X
  Flag =True
  for k in range(N):
    if List[k] == X:
      Flag = False
  if Flag:
    print(res)
  else:
    for i in range(1,103):
      med_p = X+i
      med_n = X-i
      Flag_p = False
      Flag_n = False
      for j in range(N):
        if List[j] == med_p:
          Flag_p = True
        elif List[j] == med_n:
          Flag_n = True
        else:
          pass
      if Flag_p and Flag_n:
        pass
      elif not Flag_p and Flag_n:
        res = med_p
        break
      elif Flag_p and not Flag_n:
        res = med_n
        break
      else:
        res = med_n
        break
    print(res)

Solution (Python):
X,N=map(int,input().split())
P=list(map(int,input().split()))
absP=[abs(X-i) for i in P]

def b():
    if(N==0):
        return X
    for n in range(0,N+1):
        a=X-n
        if(a not in P):
            return a
        a=X+n
        if(X+n not in P):
            return a
print(b())

Solution (Python):
import numpy as np

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

        l = []
        for i in range(-100,120):
            if i not in p:
                l.append(i)
        
        l2 = []
        if x not in p:
            print(x)
        else:
            for j in range(1,101):
                nump = x+j
                numm = x-j
                if numm in l:
                    l2.append(numm)
                if nump in l:
                    l2.append(nump)
                if len(l2)>0:
                    break
            print(l2[0])

        
    
if __name__ == '__main__':
    main()

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

Solution (Python):

X, N = [int(s) for s in input().split()]
if N == 0:
    print(X)
    exit()
P = [int(s) for s in input().split()]
Y = list(range(-10, 120))
for a in sorted(map(lambda x: (abs(x - X), x), Y), key=lambda x: [x[0], x[1]]):
    if not a[1] in P:
        print(a[1])
        exit()

print(X)

Solution (Python):
a,b = map(int,input().split())
li = list(map(int,input().split()))
countUp = a
countDown = a
ans = 0
while True:
  if countDown not in li:
    ans = countDown
    break 
  countDown = countDown - 1
  if countUp not in li:
    ans = countUp
    break
  countUp = countUp + 1 

print(ans)

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

d=150
pa = 0
px =range(102)
py = list(set(px) - set(p))

for i in py:

    if d> abs(i-x):
        pa = i
        d = abs(i-x)
    elif d == abs(i-x):
        if i < pa:
            pa =i



print(pa)

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

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

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

large = 0
for i in range(101):
    if not x + i in p:
        large = x + i
        break

small = 0
for i in range(101):
    if not x - i in p:
        small = x - i
        break

if abs(x - large) == abs(x - small):
    print(small)
elif abs(x - large) < abs(x - small):
    print(large)
else:
    print(small)

Solution (Python):
X, N = map(int, input().split())
p_list = sorted(list(map(int, input().split())), reverse = True)



if (not X in p_list) or (N == 0):
    ans = X
else:
    p_min, p_max = p_list[-1], p_list[0]
    if X < p_min:
        ans = p_min - 1
    else:
        m = min(abs(X - p_min), abs(X - p_max))
        for i in range(1, m + 2):
            if not X - i in p_list:
                ans = X - i
                break
            if not X + i in p_list:
                ans = X + i
                break

print(ans)

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

p = list(map(int,input().split()))
dev = []
mini = 0

for i in range(N):
    dev.append(abs(X-p[i]))


for i in range(N):
    if mini == dev[i]:
        break
else:
    print(X)
    exit()

mini +=1
while True:
    check = 0
    temp = 0
    for i in range(N):
        if mini==dev[i]:
            if check == 1:
                mini +=1
                break
            else:
                check +=1
                temp = p[i]
    else:
        if X-temp < 0 or temp ==0:
            print(X-mini)
            exit()
        else:
            print(X+mini)
            exit()

Solution (Python):

"""
Created on Sun Jun 14 21:22:01 2020

@author: Kei
"""

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

p = []*N

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

goal_p = X
goal_m = X
sw_p = 0
sw_m = 0

if (N ==0):
    print(X)
else:
    while(1):
        sw_p = 0
        sw_m = 0
        
        for i in range(0,N):
            if(goal_p == p[i]):
                sw_p =1
        
        for i in range(0,N):
            if(goal_m == p[i]):
                sw_m =1
        
        if(sw_m == 0):
            print(goal_m)
            break
        
        if(sw_p == 0):
            print(goal_p)
            break
        
        goal_p += 1
        goal_m -=1

Solution (Python):
import sys

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

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

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

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
b = [1]*201
for a in p:
    b[a]=0

wk = 999
idx = 0
for i in range(201):
    if wk > abs(x - b[i]*i):
        wk1 = abs(x - b[i]*i)
        idx = i
    wk = wk1

print(idx)

Solution (Python):

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


zero = [0]*101
minimum = 101

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

for i in range(N):
    zero[p[i]] = 1

for i in range(101):
    if zero[i] == 0:
        if abs(X-i) < minimum:
            minimum = abs(X-i)
            count = i

for i in range(101, 120):
    if abs(X-i) < minimum:
        minimum = abs(X-i)
        count = i

for i in range(10):
    if abs(X+i) < minimum:
        minimum = abs(X+i)
        count = -i

print(count)

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

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

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

def Main(X, N, P):
    if N == 0:
        return X
    anss = []
    for i in range(102):
        if i in P:
            continue
        else:
            ab = 1000
            for e in P:
                ab = min(ab, abs(i-e))
            anss.append((i, ab))
    anss.sort(key = lambda x: x[1])
    ans = []
    mi = anss[0][1]
    for el in anss:
        if el[1] == mi:
            ell = (abs(X-el[0]), el[0])
            ans.append(ell)
        else:
            break
    ans.sort()
    return ans[0][1]
            
        
                    
out = Main(X, N, P)
print(out)

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

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

print(ans)

Solution (Python):
import numpy as np

a = input()
a, b = a.split()
a = int(a)
if int(b) == 0:
  print(a)
  exit()
n = input()
n = [int(i) for i in n.split()]
li = list(range(-250, 250))
for i in n:
  li.remove(i)
mini = [np.inf, 0]
for i in li:
  if abs(i - a) == mini[0]:
    if i < mini[1]:
      mini = [abs(i - a), i]
  elif abs(i - a) < mini[0]:
    mini = [abs(i - a), i]
print(mini[1])

Solution (Python):
X,N = (int(x) for x in input().split())
if N==0:
    print(X)
else:
    P = [int(x) for x in input().split()]
    Target = X
    if Target not in P:
        print(Target)
    else:
        Count = 0 
        Flag  = True
        while Flag:
            Count += 1
            Target = [X-Count,X+Count]
            if Target[1] not in P:
                Flag = False
                Disp = Target[1]
            if Target[0] not in P:
                Flag = False
                Disp = Target[0]
        print(Disp)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
cnt = 0
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

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

i=[0]*201
for n in range(201):
    i[n]=n-99

ans=list(set(i) ^ set(p))
ans.sort()
dif=100
count=0
for j in range(201-N):
    dif_now=abs(X-ans[j])
    if dif>dif_now:
        dif=dif_now
        count=ans[j]
print(count)

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

num = 0
while True:
    if X+num in p_n:
        pass
    else:
        print(X +num)
        break
    num += 1
    if X - num in p_n:
        pass
    else:
        print(X - num)
        break

Solution (Python):
X, N = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]

ans = X

for i in range(0,101):
        if (X - i) not in P:
                ans = X - i
                break
        elif (X + i) not in P:
                ans = X + i
                break
print(ans)

Solution (Python):
x, n =map(int, input().split())
l = list(map(int, input().split()))
if n == 0:
    print(x) 
else:
    for i in range(n//2 + 2):
        if not(x - i in l):
            print(x-i)
            break
        elif not (x + i in l):
            print(x+i)
            break

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

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

d = {n: 1 for n in p}

a = X
b = X
while True:
    if d.get(a) != 1:
        print(a)
        break
    elif d.get(b) != 1:
        print(b)
        break
    else:
        a -= 1
        b += 1

Solution (Python):
import numpy as np


def main(X, N, a):
    a.append(10000000000)
    a.append(-10000000000)
    a.sort()
    maxn = a[0]-1
    for i in range(len(a)-1):

        if a[i] >= X:
            if a[i+1]-a[i] > 1:
                if X-maxn>a[i]+1-X:
                    maxn = a[i]+1
                break
            if X-maxn < a[i]-X:
                break
        else:
            if a[i+1]-a[i] > 1:
                if a[i+1] > X and a[i] < X:
                    maxn = X
                    break
                maxn = a[i+1]-1

    return maxn


X, N = map(int, input().split())
try:
    a = list(map(int, input().split()))
except:
    a = []
print(main(X, N, a))

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

for i in range(101):
    sub = x - i
    if sub not in ps:
        print(sub)
        break

    add = x + i
    if add not in ps:
        print(add)
        break

Solution (Python):
X, N= [int(x) for x in input().split()]
P = [int(x) for x in input().split()]

P_sub_abs = [abs(i - X) for i in P]
if(P_sub_abs.count(0) == 0):
    print(X)
    exit()
for i in range(1, 100):
    if(P_sub_abs.count(i) == 1):
        list = [X - i, X + i]
        list.remove(P[P_sub_abs.index(i)])
        print(list[0])
        exit()
    elif(P_sub_abs.count(i) == 0):
        print(X - i)
        exit()

Solution (Python):
m, n = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
diff = 10000
d = {}
if n == 0:
  print(m)
else:
  for a in arr:
    if diff > abs(m - a):
      diff = abs(m - a)
    d[a] = 1
  n = 0
  while True:
    if d.get(m + n, 0) == 0 and d.get(m  - n, 0) == 0:
      print(min((m  - n, m  + n )))
      break
    if d.get(m  + n, 0) == 0:
      print(m + n)
      break
    elif d.get(m - n, 0) == 0:
      print(m - n)
      break
    n += 1

Solution (Python):
numbers = [int(i) for i in input().split()]
sequences = [int(i) for i in input().split()]
x = numbers[0]
y = numbers[0]
a = True
if numbers[0] not in sequences:
    print(numbers[0])
    a = False
while a:
    x += 1
    y -= 1
    if y not in sequences:
        print(y)
        break
    elif x not in sequences:
        print(x)
        break

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

def is_in_p(j):
    flag = True
    for p_i in p:
        if p_i == j:
            flag = False
    return flag

abs_min = 101 
min_num = 0

for j in range(102):
    if abs(X - j) < abs_min and is_in_p(j):
        abs_min = abs(X - j)
        min_num = j
print(min_num)

Solution (Python):

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




l=list(range(-2,105))

if N >0:
    plist=list(map(int,input().split()))

    for i in range(len(plist)):
        l.remove(plist[i])



ans=[]
for i in range(len(l)):
    ans.append(abs(l[i]-X))

print(l[ans.index(min(ans))])

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

p_hash = {}
for p in p_list:
  p_hash[p] = True

i = 0
while True:
  left = x - i
  if p_hash.get(left) is None:
    print(left)
    break
  right = x + i
  if p_hash.get(right) is None:
    print(right)
    break
  i = i + 1

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

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


a = 0
for m in range(100 + 2):
    if m in p:
        continue
    else:
        if abs(x - a) > abs(x - m):
            a = m

print(a)

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

if N == 0:
    print(X)
else:
    p = sorted(p)
    for i in range(0, 100):
        if X-i not in p:
            print(X-i)
            break
        elif X+i not in p:
            print(X+i)
            break

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

i = 0
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):
X, N = map(int, input().split())
p = list(map(int, input().split()))

going = True
c = X 
co = X
count = 0

if N == 0:
    print(X)
else:
    while going:
        if p.count(c) == 0:
            print(c)
            break
        elif p.count(co) == 0:
            print(co)
            break
        c -= 1
        co += 1

Solution (Python):
x, n = map(int, input().split())
p = list(map(int,input().split()))
ux = x
dx = x
while True:
    if dx in p:
        dx -= 1
    else:
        ans1 = dx
        break
while True:
    if ux in p:
        ux += 1
    else:
        ans2 = ux
        break
if x-dx <= ux-x:
    print(dx)
else:
    print(ux)

Solution (Python):
x, n = map(int, input().split())
if(n == 0):
    print(x)
elif(n == 1):
    if(n == x):
        print(x - 1)
    else:
        print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    p2 = map(lambda a: a - x, p)
    ps = sorted(p2, key=abs)
    q = list(range((-1) * n, n))
    qs = sorted(q, key=abs)
    for i in range(n):
        if(ps[i] != qs[i]):
            print(qs[i] + x)
            break
    else:
        print(x + qs[n])

Solution (Python):
x,n=map(int,input('').split(' '))
p=input('')
if n==0:
    print(x)
else:
    p=p.split(' ')
    for a in range(n):
        p[a]=int(p[a])

    l=400
    sok=0
    for a in range(102):
        ok=1
        for b in range(n):
            if p[b]==a:
                ok=ok*0
            else:
                ok=ok*1
                sok=1

        if ok==1:
            if abs(a-x)<abs(l-x):
                l=a
            elif abs(a-x)==abs(l-x):
                if a<l:
                    l=a
                elif a>l:
                    l=l


    print(l)

Solution (Python):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
anss = [101] * 102
for i in range(102):
  if (i not in ps):
    anss[i] = abs(x - i)
m = min(anss)
for i, ans in enumerate(anss):
  if ans == m:
    print(i)
    exit()

Solution (Python):
X, N =map(int, input().split())
if N ==0:
  print(X)
  exit()
S_1 = set(map(int, input().split()))
S_2 = {i for i in range(102)}
S = S_2 - S_1
L = 1000
for s in S:
  if abs(X-s) < abs(X-L):
    L = s
print(L)

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

check = float("inf")
ans = float("inf")
for p in range(1000,-1001,-1):
    if p in p_lst:
        continue
    else:
        
        if check >= abs(p-x):
            check = abs(p-x)
            ans = p
            
print(ans)

Solution (Python):
import sys
x, n = map(int, input().split())
p = []
if n != 0:
    p = sorted(map(int, input().split()))
q = []
t = 0
for t in range(102):
    if t not in p:
        q.append(t)
m = 100000000
ans = 0
for i in q:
    if abs(x - i) < m:
        m = abs(x - i)
        ans = i
print(ans)

Solution (Python):
import sys

x,n = map(int,input().split())
p = list(map(int,input().split()))
pp = [i for i in range(-103,103)]
ans = 1000
m = 1000

for j in range(n):
    pp.remove(p[j])

for k in pp:
    if m > abs(x-k):
        m = abs(x-k)
        ans = k

print(ans)

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

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

Solution (Python):
"""
6 5
4 7 10 6 
"""
x,n = map(int, raw_input().split(' '))

ais = map(int, raw_input().split(' ')) if n else []
ais.sort()


def f(x, u, v):
	
	if u + 1 == v: return (+float('inf'), +float('inf'))
	if u < x < v: return (0,x) 	
	if x >= v: return (abs(x - (v -1)), v-1)
	if x <= u: return (abs(x - (u +1)), u + 1)
res = (+float('inf'), +float('inf'))
ais = [-1] + ais + [102]
for u,v in zip(ais,ais[1:]):
	res = min(res , f(x,u,v))

print res[1]

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




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

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

all = list(range(102))
val = 10000000000


for a in list(set(all) - set(p)):
    if abs(a - x) < val:
        ans = a
        val = abs(a - x)
        
print(ans)

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

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


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

left = x
while True:
    if left not in p:
        break
    left -= 1

right = x
while True:
    if right not in p:
        break
    right += 1

if abs(x-left) <= abs(x-right):
    print(left)
else:
    print(right)

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

MAX = 102
tbl = [False] * MAX
for t in p:
    tbl[t] = True
MIN = MAX
ans = 0
for i in range(MAX):
    if tbl[i]:
        continue
    if MIN > abs(x-i):
        ans = i
        MIN = abs(x-i)

print(ans)

Solution (Python):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
nums = list(range(-1, 102))
for p in ps:
    nums.remove(p)
min_diff = float("inf")
min_original = float("inf")
for num in nums:
    diff = abs(num - x)
    if diff < min_diff:
        min_diff = diff
        min_original = num
    elif diff == min_diff:
        if num < min_original:
            min_original = num
print(min_original)

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

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

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

diff = 0
high = low = None
while True:
    if X + diff not in P:
        high = X + diff
    if X - diff not in P:
        low = X - diff
    if high is None and low is None:
        diff += 1
        continue

    if high == low:
        print(low)
    elif low is None:
        print(high)
    else:
        print(low)
    break

Solution (Python):
x, n = map(int, input().split())
 
if n != 0:
    s = set(map(int, input().split()))
    origin_set = set(range(-1, 102))
    result_set = origin_set - s
    result_list = list(result_set)
    result_num = 1000
 
    for i in result_list:
      if abs(x-i) < result_num:
        min_num = i
        result_num = abs(x-i)
      elif abs(x-i) == result_num:
        if i < min_num:
          min_num = i
    print(min_num)
else:
  print(x)

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

l = list(range(-1,102))
s = []
  
for i in p:
  l.remove(i)

for j in l:
  s.append(abs(X-j))
  
ans = min(s)

if l.count(X+ans) == 1 and l.count(X-ans) == 1:
  print(X-ans)

elif l.count(X+ans) == 1 and l.count(X-ans) != 1:
  print(X+ans)
  
elif l.count(X+ans) != 1 and l.count(X-ans) == 1:
  print(X-ans)

Solution (Python):
def dev(y,x):
    if y<x:
        return 2*(x-y)-1
    else:
        return 2*(y-x)


x,n=map(int,input().split())
p=[int(y) for y in input().split()]
q=[dev(y,x) for y in p]
q.sort()
r=0
while r<len(q):
    if q[r]!=r:
        break
    r+=1
if r%2==0:
    print(x+r//2)
else:
    print(x-(r+1)//2)

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

tmp = [(abs(i-x), i) for i in range(0, 102) if i not in ps]
min_d = min(tmp, key=lambda x: x[0])[0]

ans = min(filter(lambda x: x[0] == min_d, tmp), key=lambda x:x[1])

print(ans[1])

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


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


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

p.sort()
gen = list(range(-5,120))

for i in p:
    gen.remove(i)

index = bisect.bisect(gen,X)

ans = 100000
ans2 = 100000

a = [gen[index-1],gen[index],gen[index+1]]

for i in range(3):
    check = abs(a[i]-X)
    if ans > check:
        ans = check
        ans2 = a[i]
    
print(ans2)

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

result = 100
AAA = result

if N == 0:
    result = X
else:
    for pi in range(-2,102):
        if pi in P:
            continue

        if pi > X:

            if abs(X - AAA) <= abs(X - pi):
                result = AAA
            else:
                result = pi

            break

        AAA = pi

print(result)

Solution (Python):


from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


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

diff = INF
res = None

for i in range(-200, 200):
    if i in P:
        continue
    if abs(x - i) < diff:
        res = i
        diff = abs(x - i)

print(res)

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

if not X in p:
    print(X)
else:
    for i in range(1, 101):
        if not X - i in p:
            print(X - i)
            exit()
        elif not X + i in p:
            print(X + i)
            exit()

Solution (Python):
pre = input().split()
X = int(pre[0])
N = int(pre[1])

if N == 0:
  print(X)
else:
  pre = input().split()
  p = [int(s) for s in pre]

  list = [0] * 102

  for i in range(len(p)):
    list[p[i]] = 1
  

  for i in range(55):
    if list[X-i] == 0:
      print(X-i)
      break
    if list[X+i] == 0:
      print(X+i)
      break

Solution (Python):
X,N = map(int,input().split(" "))
if N == 0:
    print(X)
else:
    p = [int(i) for i in input().split(" ")]
    if not(X in p):
        print(X)
    else:
        un = sorted([i for i in p if i < X],reverse = True)
        hi = sorted([i for i in p if i > X])
        X1 = X-1
        X2 = X+1
        while(1):
            if not(X1 in un):
                print(X1)
                break
            if not(X2 in hi):
                print(X2)
                break
            X1 -= 1
            X2 += 1

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

ans = x

if x not in p:
    ans = x
else:
    for i in range(1, 52):
        if x - i not in p:
            ans = x - i
            break
        elif x + i not in p:
            ans = x + i
            break
print(ans)

Solution (Python):
X, N = map(int, input().split())
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,n = map(int,input().split())

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

num_list = list(map(int,input().split()))
i = 0

while True:
  if (x-i) not in num_list:
    print(x-i)
    break
  elif (x+i) not in num_list:
    print(x+i)
    break
  i += 1

Solution (Python):

if __name__ == "__main__":
    x, n = [int(a) for a in input().split()]
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    ans =-1
    if x not in p:
        print(x)
        exit()
    while True:
        i += 1
        if (x-i) not in p:
            ans = x-i
            break
        elif (x+i) not in p:
            ans = x+i
            break
    print(ans)

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

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

for i in range(len(p)):
    ans1 -= 1
    ans2 += 1
    if ans1 not in p:
        print(ans1)
        exit()
    if ans2 not in p:
        print(ans2)
        exit()
print(X)

Solution (Python):
x,n = (int(x) for x in input().split())
try:
  p = [int(x) for x in input().split()]
  i = 0
  while 1:
    ans1 = x - i
    ans2 = x + i
    if ans1 not in p:
      print(ans1)
      break
    if ans2 not in p:
      print(ans2)
      break
    i = i + 1
except EOFError:
  print(x)

Solution (Python):
import sys

X,N=(int(x) for x in input().split())
if N==0:
  print(X)
  sys.exit()

P=input().split()
P_int = [int(s) for s in P]



if not X in P_int:
  print(X)
  sys.exit()

for i in range(1,100):
  if not (X-i) in P_int:
    print(X-i)
    sys.exit()
  
  if not (X+i) in P_int:
    print(X+i)
    sys.exit()

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

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

if N == 0:print(X)
else:
    for i in range(0,100):
        if not X-i in L:
            print(X-i)
            break
        if not X+i in L:
            print(X+i)
            break

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

for i in range(100):
    if p.count(X-i) == 0:
        print(X-i)
        break
    elif p.count(X+i) == 0:
        print(X+i)
        break

Solution (Python):
x, n=map(int, input().split())
try:
  l=list(map(int, input().split()))
except EOFError:
  print(x)
  exit()
for i in range(101):
  if x+i in l and x-i in l:
    continue
  elif x+i in l:
    print(x-i)
    exit()
  elif x-i in l:
    print(x+i)
    exit()
  else:
    print(x-i)
    exit()

Solution (Python):
import numpy as np
import sys
import math
import itertools
import collections

X , N = map(int,input().split())
if N != 0:
    P = list(map(int,input().split()))
else:
    print(X)
    sys.exit()

s = set(P)

m = 1000
ans = None
for i in range(-1,102):
    if i not in s:
        if m > abs(X-i):
            ans = i
            m = abs(X-i)

print(ans)

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

res = 10**15
for i in range(-120,120):
  if i in P: continue
  if abs(i-X) < abs(res-X):
    res = i
print(res)

Solution (Python):
x,n=map(int,input().split())
try:
 P = list(map(int,input().split()))
except EOFError:
  print(x)
else:
  ans1 = x
  ans2 = x
  if x not in P:
    print(x)
  else:
    while True:
        ans1 += 1
        ans2 -= 1
        if ans1 not in P and ans2 not in P:
          print(ans2)
          break
        elif ans1 in P and ans2 not in P:
          print(ans2)
          break
        elif ans2 in P and ans1 not in P:
          print(ans1)
          break

Solution (Python):
x, n = map(int, input().split())
pli = [int(i) for i in input().split()]
ans = 0
for s in range(1, 51):
    if not x in pli:
        ans = x
    elif x in pli and not x - s in pli and not x + s in pli:
        ans = x - s
        break
    elif x in pli and x - s in pli and not x + s in pli:
        ans = x + s
        break
    elif x in pli and not x - s in pli and x + s in pli:
        ans = x - s
        break
    
print(ans)

Solution (Python):
x,n = map(int,input().split())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True



queue = [x]
while(len(queue)>0):
    now = queue.pop(0)
    if(now <= 0 or now >=101):
        print(now)
        break
    if(mp[now]==False):
        print(now)
        break
    
    if(now==x):
        queue.append(now-1)
        queue.append(now+1)
    if(now < x):
        queue.append(now-1)
    if(now > x):
        queue.append(now+1)

Solution (Python):
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
else:
  l = list(map(int, input().split()))
  
  ze = [0 for i in range(101)]
  
  for i in range(n):
    ze[abs(x-l[i])] += 1
    
  if ze[0] == 0:
    print(x)
  else:
    for i in range(1, 101):
      if ze[i] < 2:
        if x-i not in l:
          print(x-i)
          sys.exit()
        else:
          print(x+i)
          sys.exit()

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

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

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

else:
    print(x)

Solution (Python):
X, N = map( int, input().split() )
ret = X
if N > 0:
  P = sorted( list( map( int, input().split() ) ))
  dis = 10 ** 18
  for i in range( 110, -1, -1 ):
    if not i in P:
      if dis - abs( i - X ) >= 0:
        ret = i
        dis = abs( i - X )
  
print( ret )