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

if n != 0:
  s = set(list(map(int,input().split())))
else:
  s = []
diff = 10**18
ans = 10**18
  
for i in range(-10000, 10000):
  if i in s:
    continue
  else:
    if abs(x - i) < diff:
      ans = i
      diff = abs(x - i)
      
print(ans)

Solution (Python):
import sys


def log(s):
    
    pass


def output(x):
    print(x, flush=True)


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


def main():
    x, n = tuple(input_ints())
    pp = input_ints()

    d = 0
    while True:
        if not x-d in pp:
            print(x - d)
            break
        if not x+d in pp:
            print(x + d)
            break
        d += 1

main()

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



x = y = X
true=[]
jud = True
while jud:
    if x not in p:
        true.append(x)
        break
    x += 1
while jud:
    if y not in p:
        true.append(y)
        break
    y -= 1

abs=[abs(t-X) for t in true]

true_list=[i for i,a in enumerate(abs) if a==min(abs)] 
true_list2=[true[i] for i in true_list]
print(min(true_list2))

Solution (Python):
X,N = map(int,input().split())
 
p = list(map(int,input().split()))
 
import sys
for i in range(102):
 
    if X-i not in p:
        print (X-i)
        sys.exit()
    elif X+i not in p:
        print (X+i)
        sys.exit()

Solution (Python):
import sys
x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
p = tuple(map(int, input().split()))
for i in range(100):
    if (x-i in p) == False:
        print(x-i)
        break
    if (x+i in p) == False:
        print(x+i)
        break

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]:
    a = X + s * d
    if p.count(a) == 0:
      print(a)
      exit(0)

Solution (Python):
X,N = map(int,input().split())
 
p = list(map(int,input().split()))
 
import sys
for i in range(200):
 
    if X-i not in p:
        print (X-i)
        sys.exit()
    elif X+i not in p:
        print (X+i)
        sys.exit()

Solution (Python):

X, N = map(int, input().split()) 
num_list = list(map(int, input().split())) 
for i in range(len(num_list)):
    num_list[i] = num_list[i]-X
for i in range(101):
    if (-i in num_list) is False:
        print(X-i)
        break
    if (i in num_list) is False:
        print(X+i)
        break

Solution (Python):
X,N = map(int,input().split())
if N == 0:
    print(X)
    exit()
else:
    M = list(map(int,input().split()))
    up = X
    down = X
    ans = []
    while ans == [] :
        if up in M and down in M:
            up += 1
            down -= 1
        elif down in M:
            ans.append(up)
        else:
            ans.append(down)
    print(min(ans))

Solution (Python):

x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = list(map(int, input().split()))
    ans = 10**9
    L = {P[i]:0 for i in range(n)}
    for i in range(-200, 201):
        if i not in L.keys():
            if abs(ans - x) > abs(i - x):
                ans = i
    print(ans)

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

Solution (Python):
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
p=list(map(int,input().split()))
num=10**6
ans=0
np=[]
for i in range(0,201):
  if not i in p:
    np.append(i)
for i in np:
  if num>abs(X-i):
    num=abs(X-i)
    ans=i
print(ans)

Solution (Python):
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self




target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  
  a = target - i 
  if a not in nums:
    print(a)
    exit()

  b = target + i 
  if b not in nums:
    print(b)
    exit()

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

cur_dist,num = int(1e10),int(1e10)

for i in range(-100,201):
  if i in arr:
    continue
  dist = abs(i-x)
  if dist < cur_dist:
    cur_dist = dist
    num = i

print(num)

Solution (Python):
def solve():
    X, N = map(int, input().split())
    ps = set(map(int, input().split()))

    for i in range(100):
        if X - i not in ps:
            return X - i
        if X + i not in ps:
            return X + i
        

def main():
    print(solve())


if __name__ == "__main__":
    main()

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

    candidates = set(range(102))

    for p in ps:
        candidates.discard(p)

    nearest = 0
    distance = X
    for c in candidates:
        d = abs(X-c)
        if distance > d:
            nearest = c
            distance = d

    return nearest


def main():
    print(solve())


if __name__ == "__main__":
    main()

Solution (Python):
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self




target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  a = target - i
  if a not in nums:
    print(a)
    exit()

  b = target + i
  if b not in nums:
    print(b)
    exit()

Solution (Python):
X, N = map(int, input().split())
ans={}
for P in list(map(int, input().split())):
    ans[X-P]=1

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

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
diff = []
y = [i for i in range(-1, 102) if i not in p]
for i in y:
  z = abs(x - i)
  diff.append(z)

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd

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

for d in range(X+1):
    for s in [-1, 1]:
        ans = X + d * s
        if P.count(ans) == 0:
            print(ans)
            exit(0)

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


z=float("inf")
ans_temp=[0,0]
ans=[0,0]

y=[i for i in range(-1,102) if i not in p]

for i in y:
  if z>abs(x-i):
    ans[0]=abs(x-i)
    ans[1]=i
  elif z==abs(x-i):
    ans_temp[0]=abs(x-i)
    ans_temp[1]=i
    if ans_temp[1]<ans[1]:
      ans[1]=ans_temp[1]
  z=abs(x-i)
print(ans[1])

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

while True:
  if j not in p:
    ansb = x - j
    break
  else:
    j -= 1

print(i if ansa<ansb else j)

Solution (Python):
x, n = map(int, input(). split())
p = []
if n > 0:
  p = list(map(int, input(). split()))
if n == 0:
  print(x)
else:
  if x not in p:
    print(x)
  else:
    d = 1
    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):
import sys
sys.setrecursionlimit(10000000)
from collections import defaultdict
import math

x, n = map(int, input().split())
P = list(map(int, input().split()))
if len(P) == 0:
    print(x)
    exit()
for i in range(x, max(P)+2):
    if i not in P:
        a = i
        break
for i in range(x, -1, -1):
    if i not in P:
        b = i
        break
if abs(a-x) < abs(b-x):
    print(a)
else:
    print(b)

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

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

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

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

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

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

if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  for j in range(0, int(n/2)+ 2):
    
    if x-j not in p:
      print(x-j)
      break
    else:
      if x+j not in p:
        print(x+j)
        break

Solution (Python):
x, n = map(int, input().split())
diff, ans = 10000, x
if n > 0:
    vals = set(map(int, input().split()))
    for i in range(300):
        if i not in vals and diff > abs(x-i):
            ans = i
            diff = abs(x - i)
print(ans)

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

for i in range(0, 100):
    a = x - i
    b = x + i

    if a not in p:
        print(a)
        break
    elif b not in p:
        print(b)
        break

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

for i in range(0, 100):
    a = x - i
    b = x + i

    if a >= 0 and a not in p:
        print(a)
        break
    elif b <= 101 and b not in p:
        print(b)
        break

Solution (Python):
x, n = map(int, input().split())
s = set(map(int, input().split()) if n != 0 else "")

i = 0
while x + i in s:
    if i >= 0: i += 1
    i *= -1

print(x + i)

Solution (Python):
x, n = map(int, input().split())
s = set(map(int, input().split()) if n != 0 else "")

i = 0
while True:
    k = x + i
    if k not in s:
        print(k)
        break

    if i >= 0: i += 1
    i *= -1

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

ans = 0
for i in range(102):
    if i not in p and abs(ans - x) > abs(i - x):
        ans = i

print(ans)

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

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

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

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

Solution (Python):
Input = input().split()
X = Input[0]
X = int(X)
N = Input[1]
N = int(N)
if N != 0:
    P = input().split()
    Z = 0
    A = 0
    while Z < 1:
        B = X + A
        C = X - A
        B = str(B)
        C = str(C)
        if not(C in P):
            D = C
            Z = 1
            break
        if not(B in P):
            D = B
            Z = 1
            break
        A += 1
else:
    D = X

print(D)

Solution (Python):


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

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

flag = True
x = 0
count = 0

while flag:
    x = X - count
    if(x not in P):
        print("{}".format(x))
        break

    x = X + count
    if(x not in P):
        print("{}".format(x))
        break

    count += 1

Solution (Python):
import sys

x, n = map(int, input().split())
s = set(map(int, input().split()) if n != 0 else "")

i = 0
while True:
    for j in range(2):
        k = x - i * (-1)**j
        if k not in s:
            print(k)
            sys.exit()
    i += 1

Solution (Python):
x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp:
    ret = i
    tmp = abs(x-i)
print(ret)

Solution (Python):
X, N = map(int, input().split())
p_i = list(map(int, input().split()))
for i in range(len(p_i)+1):
    if X-i not in p_i:
        print(X-i)
        break
    elif X+i not in p_i:
        print(X+i)
        break

Solution (Python):
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
x,n=map(int,stdin.readline().split())
a=set(map(int,stdin.readline().split()))
if(x not in a):
    print(x)
else:
    diff=1
    while(True):
        if(x-diff not in a):
            print(x-diff)
            break
        elif(x+diff not in a):
            print(x+diff)
            break
        diff+=1

Solution (Python):
X,N = map(int, input().split())
p = input()
p = p.split()
p = [int(c) for c in p]
Y = Z = X
flug = 0
if X not in p:
    print(X)
if X in p:    
    for i in range(1,100):
        Y -= 1
        Z += 1
        if Y not in p:
            print(Y, end = " ")
            flug = 1
        elif Z not in p:
            print(Z)
            flug = 1
        if flug == 1:
            break

Solution (Python):
x,n=map(int,input().split())
if(n==0):
  print(x)
  exit(0)
a=list(map(int,input().split()))
f=set(a)
mi=1000000
r=100000000
for i in range(-1000,1001):
  if(i in f):
    continue
  if(abs(x-i)<mi):
    mi=abs(x-i)
    r=i
print(r)

Solution (Python):
import sys
import math
import decimal

def input():
    return sys.stdin.readline()[:-1]

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

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

Solution (Python):
xn = input().split()
X = int(xn[0])
N = int(xn[1])
A = [int(x) for x in input().split()]
li = [x for x in range(102)] 
li2 = list(x for x in li if x not in A )
d_tmp = 1200
ans_tmp = -1
for i in li2:
    d = abs(X-i)
    if d < d_tmp:
        d_tmp = d
        ans_tmp = i
print(ans_tmp)

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

if p==[]: print(X); exit()

p.sort()
l,r=p[0]-1,p[-1]+1
p=set(p)
sa=float('inf')
ans=float('inf')
for i in range(l,r+1):
    if (i not in p) and (abs(X-i)<sa):
        ans=i
        sa=abs(X-i)

print(ans)

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

d = [abs(x-i) for i in p]
if 0 not in d:
    print(x)
    exit()
else:
    cur = 1
    while True:
        if d.count(cur) == 0:
            print(x-cur)
            break
        elif d.count(cur) == 1:
            if x-cur not in p:
                print(x-cur)
                break
            else:
                print(x+cur)
                break
        else:
            cur += 1

Solution (Python):
x ,n = map(int, input().split())
s = list(map(int, input().split()))
number = list(range(0,102))
min = 100
if n == 0:
  print(x)
  exit()
  
for i in range(n):
  number.remove(s[i])

for i in range(102 - n):
  if min > abs(x - number[i]):
    min = abs(x - number[i])
    j = i
print(number[j])

Solution (Python):
X,N,*P=map(int,open(0).read().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):

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

while(True):
    if x in a:
        x-=1
    else:
        break
    
    if xx in a:
        xx+=1
    else:
        x = xx
        break

print(x)

Solution (Python):
x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    df -= 1

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

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

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


main()

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
result = []
for i in range(102):
    if i in p:
        continue
    else:
        result.append([abs(i-x), i])
result.sort()
print(result[0][1])

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

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

Solution (Python):
x,n = map(int, input().split())
a = list(map(int, input().split()))
lis = [True]*102
for i in a:
    lis[i] = False
ho = 0
while True:
    if not x-ho < 0:
        if lis[x-ho]:
            print(x-ho)
            exit()
    if not x+ho > 101:
        if lis[x+ho]:
            print(x+ho)
            exit()
    ho+=1

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

Solution (Python):
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x - i)
    sys.exit()
  if x + i not in lst:
    print(x + i)
    sys.exit()

Solution (Python):
X, N = map(int, input().split())
P=[int(_) for _ in input().split()]
for s in range(X+1):
  for t in [-1, +1]:
    u=X+s*t
    if P.count(u)==0:
      print(u)
      exit()

Solution (Python):
def run(x, n, num_array):
    '''
    '''
    if len(num_array) == 0:
        print(x)
        return
    
    i = 0
    while True:
        if x - i not in num_array:
            print(x - i)
            return
        elif x + i not in num_array:
            print(x + i)
            return
        i += 1
        

if __name__ == '__main__':
    x, n = list(map(int, input().split()))
    num_array = list(map(int, input().split()))
    run(x, n, num_array)

Solution (Python):
import numpy as np

X,N = map(int, input().split())
P = np.array(list(map(int,input().split())), dtype=np.int32)
num = np.arange(0,102)
kouho = np.setdiff1d(num,P)
ans = kouho[np.argmin((np.abs(kouho-X)))]
print(ans)

Solution (Python):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
P = list(map(int, input().split()))
 
for i in range(X+1):
  for d in [-1, +1]:
    if not (X+i*d) in P:
      print(X + i*d)
      exit()

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

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

Solution (Python):
import sys

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

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

diff_prev = 10**10
for i in range(-1, 102):
    if i in P:
        continue

    diff_now = abs(X - i)
    if diff_prev <= diff_now:
        break
    else:
        diff_prev = diff_now
        i_prev = i

print(i_prev)

Solution (Python):
x , n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = set(map(int,input().split()))
i = 0
while True:
    e = x-i
    if not e in p:
        print(x-i)
        exit()
    d = x+i
    if not d in p:
        print(x+i)
        exit()

    i += 1

Solution (Python):
import sys
x,n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
data = [int(i) for i in input().split()]
for dif in range(100):
  if x - dif not in data:
    print(x - dif)
    break
  elif x + dif not in data:
    print(x + dif)
    break

Solution (Python):
import numpy as np
[x, N] = list(map(int, input().split()))
if N != 0:
  P = list(map(int, input().split()))
  P_max = max(P) + 2
  P_mini = min(P) - 1
  if P_mini <= x <= P_max:
    A = list(range(P_mini, P_max))
    for p in P:
      A.remove(p)
    delta = [np.abs(x - a) for a in A]
    ind = delta.index(min(delta))
    ans = A[ind]
  else:
    ans = x
else:
  ans = x
    
print(ans)

Solution (Python):
"""
    Satwik_Tiwari ;) .
    16 june , 2020  - Tuesday
"""



from __future__ import division, print_function

from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase


import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter  
from itertools import combinations as comb 
from itertools import permutations as permutate
from bisect import bisect_left as bl


from bisect import bisect_right as br
from bisect import bisect





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)






mod = 1000000007
def inp(): return sys.stdin.readline().rstrip("\r\n") 
def out(var): sys.stdout.write(str(var))  
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(a,b):
    ans = 1
    while(b>0):
        if(b%2==1):
            ans*=a
        a*=a
        b//=2
    return ans
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def isPrime(n) : 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True




def solve():
    x,n = sep()
    a = lis()
    cnt = [0]*(101)
    for i in range(n):
        cnt[a[i]] +=1

    ans1= -1
    num = x
    while(num >0):
        if(cnt[num] == 0):
            ans1 = num
            break
        num-=1
    ans2 = -1
    num = x
    while(num < 101):
        if(cnt[num] == 0):
            ans2 = num
            break
        num+=1
    
    if(ans1 == -1):
        ans1 = 0
    if(ans2 == -1):
        ans2 = 101

    if(abs(x-ans1) < abs(x-ans2)):
        print(ans1)
    elif(abs(x-ans1) == abs(x-ans2)):
        print(ans1)
    else:
        print(ans2)



testcase(1)

Solution (Python):
def serch_1(b,x):
    i=1
    an=0
    while 1:
        if b.count(x+i)==0:
            an=x+i
            break
        else:
            i=i+1
    return an

def serch_2(b,x):
    i=1
    an=0
    while 1:
	    if b.count(x-i)==0:
		    an=x-i
		    break
	    else:
		    i=i+1
    return an
def hikaku(a,b,x):
    if abs(a-x)>=abs(b-x):
    	return b
    else:
        return a
s = list(map(int,input().split()))

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

x=s[0]
n=s[1]
if a.count(x)==0:
	print(x)
else:
	print(hikaku(serch_1(a,x),serch_2(a,x),x))

Solution (Python):
import sys

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

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

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

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

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 x-i not in p:
            print(x-i)
            exit()
        elif x+i not in p:
            print(x+i)
            exit()



main()

Solution (Python):
X,N=map(int,input().split())
P=set()
if N!=0:
  P=set(list(map(int,input().split())))
for i in range(100):
  a=X-i
  if a not in P:
    print(a)
    exit(0)
  a=X+i
  if a not in P:
    print(a)
    exit(0)

Solution (Python):
N, M = map(int, input().split())
L = list(map(int, input().split()))

if N not in L:
  print(N)
else:
  for i in range(N,10000000000):
    i +=1
    if i not in L:
      box = i
      break
  for j in reversed(range(-10000000000, N+1)):
    j -=1
    if j not in L:
      boxm = j
      break
  if abs(N - abs(box)) >= abs(N - abs(boxm)):
    print(boxm)
  else:
    print(box)

Solution (Python):



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


if x not in p:
    ans = x
else:
    j = 1
    while True:
        if (x-j) not in p:
            ans = x - j
            break
        if (x+j) not in p:
            ans = x + j
            break
        j += 1
print(ans)

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

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

for i in range(51):
    if x-i not in P:
        print(x-i)
        break
    elif x+i not in P:
        print(x+i)
        break

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

if N == 0:
  print(X)
  sys.exit()
  
if X == 100 and N == 100:
  print(-100)
  sys.exit()
  
  
P = list(map(int, input().split()))

lis = []
for i in range (-100,102,1):
    if i not in P:
        lis.append(i)


        
        
        
ans = 10**18
suzi = 0
lis2 = []
for j in lis:
    num = abs(X-j)
    if num < ans:
        ans = num
        suzi = j

print(suzi)

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

ans,ansdiff = -1,1000000

for i in range(-1,102):
  if i in P:
    continue
    
  wdiff = abs(X-i)
  if wdiff < ansdiff:
    ansdiff = wdiff
    ans = i
  elif wdiff == ansdiff:
    if ans > i:
      ans = i
      
print(ans)

Solution (Python):
x, n = map(int, input().split(" "))
v = [i for i in range(102)]
min_val = 100
ans_val = 0

if n != 0:
    p = list(map(int, input().split(" ")))    
    for index in p:
        v[index] = 101


for v_val in v:
    if(min_val > abs(v_val - x)):
        ans_val = v_val
        min_val = min(min_val, abs(v_val - x))
    



print(ans_val)

Solution (Python):
li1 = list(map(int, input().split()))
li2 = list(map(int, input().split()))
re = li1[0]
n = 1
while True:
    if li1[0] not in li2:
        re = li1[0]
        break
    if li1[0] - n not in li2:
        re = li1[0] - n
        break
    if li1[0] + n not in li2:
        re = li1[0] + n
        break
    n += 1

print(re)

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

def solve(X, P):
    for i in range(102):
        if X-i not in P:
            return X-i
        if X+i not in P:
            return X+i
        
print(solve(X,P))

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


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

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


dist_min=N
min_value=X




for i in range(X+N,X-N-1,-1):
	flag=False
	for j in range(N):
		if(i==p[j]):
			flag=True
	if( flag == True):
		continue
	
	
	dist = abs(X-i)
	
	if ( dist==dist_min ):
		if(i<min_value):
			min_value = i
	elif ( dist < dist_min):
		dist_min = dist
		min_value = i

print(min_value)

Solution (Python):
x,y=map(int,input().split())
if y>0:
  l=list(map(int,input().split()))
  for i in range(len(l)+1):
    if x-i not in l:
      print(x-i)
      break
    if x+i not in l:
      print(x+i)
      break
else:
  print(x)

Solution (Python):
def fac(l,li):
    for i in range(len(li)+1):
        if l-i not in li:
            return(l-i)
        if l+i not in li:
            return(l+i)

l,n = map(int,input().split())
if n>0:
    li = list(map(int,input().split()))
    print(fac(l,li))
else:
    print(l)