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):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))


ans=9999
diff=9999

x,n=nm()
p=set(nl())

for i in range(102):
  if i not in p:
    if abs(x-i)==diff:
      if i<ans:
        ans=i
    elif abs(x-i)<diff:
      diff = abs(x-i)
      ans = i

print(ans)

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

count = 0

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

Solution (Python):



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

    if X not in p:
        return X

    for i in range(1, 100):
        if X-i not in p:
            return X-i
        
        if X+i not in p:
            return X+i


print(main())

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

upper = x
for i in range(n + 1):
    if x + i not in ps:
        upper = x + i
        break

lower = x
for i in range(n + 1):
    if x - i not in ps:
        lower = x - i
        break

if upper - x < x - lower:
    print(upper)
else:
    print(lower)

Solution (Python):
import sys

def main():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        sys.exit()
    p = tuple(map(int, input().split()))
    cnt = 0
    while True:
        xt = x - cnt
        if xt not in p:
            print(xt)
            sys.exit()
        xt2 = x + cnt
        if xt2 not in p:
            print(xt2)
            sys.exit()
        cnt += 1

if __name__ == '__main__':
    main()

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

res = 10000

for i in range(-200, 200):
    if i in P:
        continue

    if abs(X - res) > abs(X - i):
        res = i

print(res)

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

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

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

mindiff = 10*10
ans=-1
for i in range(-10,200):
    if i in p:
        continue
    if abs(i - x) < mindiff:
        ans = i
        mindiff = abs(i-x)
print(ans)

Solution (Python):
from collections import *
from math import *

x,n = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
for i in range(55):
	y = x - i
	if y not in a:
		print(y)
		break
	y = x + i
	if y not in a:
		print(y)
		break

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

Solution (Python):
X, N = map(int, input().split())
ans = sorted(list(set(range(-50, 51)) - set([Y - X for Y in list(map(int, input().split()))])), key=lambda x: abs(x))
if len(ans) == 1:
    print(X + ans[0])
elif ans[0] == - ans[1]:
    print(X + min(ans[0], ans[1]))
else:
    print(X + ans[0])

Solution (Python):
X, N = map(int, input().split())
P=list(map(int,input().split()))
if not X in P:
  print(X)
  exit()
for i in range(1,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,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

x,n = m()

p = l()



ans = Max
ab = Max
dp = [0 for i in range(102)]
for i in p:
	dp[i] = 1

for i in range(102):
	if dp[i] != 1 and abs(x - i) < ab:
		ab = abs(x - i)
		ans = i
print(ans)

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

p = set(p)

now = 10**29
for i in range(102):
    if not i in p:
        if abs(i-X)<now:
            now = abs(i-X)

if not X-now in p:
    print(X-now)
else:
    print(X+now)

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

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

tmp = -1
for i in range(-1, 110):
    if i not in p:
        tmp = i if abs(X - tmp) > abs(X - i) else tmp
    
print(tmp)

Solution (Python):
import sys
x,n = map(int,input().split())
p = list(map(int,input().split()))
val = x
val_neg = x
val_pos = x
i = 1
while True:
    if val not in p:
        print(val)
        sys.exit()
    else:
        if val_neg not in p:
            print(val_neg)
            sys.exit()
        elif val_pos not in p:
            print(val_pos)
            sys.exit()
        else:
            val_neg -= i
            val_pos += i

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

L = []
for k in range(0,200):
    if k not in p:
        L.append(k)

temp = 100000
ans = -1
for e in L:
    if temp > abs(e-X):
        temp = abs(e-X)
        ans = e
print(ans)

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

    ans = [10**4, 10**4]
    for i in range(102):
        if i not in p:
            if ans[1] == abs(x-i):
                ans[0] = min(ans[0], i)
            elif ans[1] > abs(x-i):
                ans[0] = i
                ans[1] = abs(x-i)
    print(ans[0])

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

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    X, N = ZZ()
    P = set(ZZ())
    sa, ans = 200, 0
    for i in range(105):
        if i in P: continue
        if abs(X-i) < sa:
            sa = abs(X-i)
            ans = i
    print(ans)

    return

if __name__ == '__main__':
    main()

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

for diff in range(200):
    a = x - diff
    if a not in p:
        print(a)
        exit()

    a = x + diff
    if a not in p:
        print(a)
        exit()

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

x, n = get_ints()
ps = get_ints()
ps.sort()
ans = 10000000
d = 1000000
for i in range(102):
    if i in ps:
        continue
    nd = abs(x - i)
    if nd < d:
        ans = i
        d = nd

print(ans)

Solution (Python):
x, n = [int(i) for i in input().split()]
tmp = input()
if len(tmp) == 0:
  print(x)
else:
  ps = set([int(i) for i in tmp.split()])
  e = 0
  while True:
    if (x - e) not in ps:
      print(x - e)
      break
    if (x + e) not in ps:
      print(x + e)
      break
    e += 1

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

i=0
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()))

ans=1000
for i in range(0,102):
    if i in p:
        continue
    if abs(ans-X)>abs(i-X):
        ans=i
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X, N = mapint()
Ps = set(list(mapint()))
now = X
for i in range(1000):
    if not now-i in Ps:
        print(now-i)
        break
    if not now+i in Ps:
        print(now+i)
        break

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

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys


buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, N, P):
    cand = sorted(list(set(range(1000)) - set(P)))
    ans = (INF, 0)
    for n in cand:
        y = abs(X-n)
        ans = min(ans, (y, n))
    return ans[1]





def main():
    X, N = read_int_n()
    P = read_int_n()
    print(slv(X, N, P))


if __name__ == '__main__':
    main()

Solution (Python):









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


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

Solution (Python):
import sys

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

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

nums = list(range(-10, 110))

for p in P:
    nums.remove(p)

answer = min(nums, key=lambda x: (abs(x - X), x))
print(answer)

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

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

if n:
    p = [int(x) for x in input().split()]
else:
    p = []

a, b = -1, 101
p.sort()
chk = [0] * 101

for x in p:
    chk[x] = 1

for x in range(k, -1, -1):
    if chk[x] == 0:
        a = x
        break

for x in range(k, 101):
    if chk[x] == 0:
        b = x
        break

if k - a <= b - k:
    print(a)
else:
    print(b)

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

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

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

    if x in inlis:
        for i in range(1, 100):
            if x - i in inlis:
                if x + i in inlis:
                    pass
                else:
                    print(x+i)
                    exit()
            else:
                print(x-i)
                exit()
    else:
        print(x)
    
if __name__ == "__main__":
    main()

Solution (Python):
x,y=map(int,input().split())
if y==0:
  print(x)
else:
  l=set(list(map(int,input().split())))
  if x in l:
    i=1
    while True:
      if not x-i in l:
        print(x-i)
        quit()
      elif not x+i in l:
        print(x+i)
        quit()
      i+=1
  else:
    print(x)

Solution (Python):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


x, n = inpl()
p = set(inpl())
dif = 0

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

Solution (Python):
X,N = [int(v) for v in input().split()]
P = [int(v) for v in input().split()]
p_f = [False for _ in range(201)]

for p in P:
    p_f[p] = True

ans = 0
for i in range(100):
    if not p_f[X-i]:
        ans = X-i
        break
    elif not p_f[X+i]:
        ans = X+i
        break
print(ans)

Solution (Python):
import bisect
X, N = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
s = set([i for i in range(102)])

for x in p:
    s.remove(x)

s = sorted(list(s))

id = bisect.bisect_left(s, X)
a = s[id-1]
b = s[id]
ans = a
if abs(a-X) > abs(b-X):
    print(b)
else:
    print(a)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

ans = -1
nums = [True]*105
for p in P:
    nums[p] = False

MIN = 10**9
for i in range(105):
    if nums[i]:
        if MIN>abs(i-X):
            MIN = abs(i-X)
            ans = i

print(ans)

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

ans = 101
minD = 105
for i in range(102):
    if i in setP: continue
    diff = abs(i-X)
    if diff < minD:
        ans = i
        minD = diff

print(ans)

Solution (Python):
def resolve():
    X,N = map(int,input().split())
    if N == 0:
        print(X)
        return
    p = set(map(int,input().split()))
    p_var = set(range(-100,102))-p
    print(min(p_var,key= lambda x: abs(X-x) ) )
resolve()

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
a=[0]*102
for i in range(len(p)):
    a[p[i]]=1
sa=500
for j in range(len(a)):
    if a[j]==0 and sa>abs(x-j):
        m=j
        sa=abs(x-j)
print(m)

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


if __name__ == '__main__':
    resolve()

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

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

a = input().split()
for i in range(len(a)):
  a[i] = int(a[i])

if x not in a:
  print(x)
else:
  sa = 1
  while True:
    if x-sa not in a:
      print(x-sa)
      break
    if x+sa not in a:
      print(x+sa)
      break
    sa += 1

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

st = set(ps)

for i in range(100):
    if x - i not in st:
        print(x - i)
        exit(0)
    elif x + i not in st:
        print(x + i)
        exit(0)

Solution (Python):
import sys
input=sys.stdin.readline
x,n=map(int,input().split())
p=list(map(int,input().split()))
ans=[10**9]*102
for i in range(102):
    if not i in p:
        ans[i]=abs(i-x)
m=0
ms=10**9
for i in range(102):
    if ans[i]<ms:
        ms=ans[i]
        m=i
print(m)

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

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

x, n = rm()
if n >= 1:
  li = rl()
else:
  print(x)
  exit()
for i in range(101):
  if (x-i) not in li:
    print(x-i)
    exit()
  elif (x + i) not in li:
    print(x+i)
    exit()

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

Solution (Python):
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

x, N = MAP()
A = LIST()

S = set(A)
i = 0
if x not in S:
    print(x)
    exit()
l = r = x
while 1:
    l -= 1
    r += 1
    if l not in S:
        print(l)
        break
    if r not in S:
        print(r)
        break

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

min_diff = 10000000
ans = 0
for i in range(-200, 201):
    if i not in p:
        if abs(X - i) < min_diff:
            ans = i
            min_diff = abs(X - i)
print(ans)

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

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

A = [i for i in range(max(P)+2) if i not in P]
X = abs(x-A[0])
ans = A[0]
for a in A[1:]:
    if abs(x-a) < X: 
        X = abs(x-a)
        ans = a
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


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

    i = 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)


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    X,N = map(int,input().split())
    P = set(map(int,input().split()))
    ans = -1
    M = INF
    for i in range(X - 105,X + 105):
        if i not in P:
            if M > abs(i - X):
                ans = i
                M = abs(i - X)
    print(ans)
if __name__ == '__main__':
    main()

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

ans1 = X
ans2 = X

while True:
  if ans2 not in p_list:
    print(ans2)
    exit()
  if ans1 not in p_list:
    print(ans1)
    exit()

  ans1 += 1
  ans2 -= 1

Solution (Python):






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

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

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

Solution (Python):
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
p=list(map(int,input().split()))
for i in range(102):
  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=sorted(list(map(int,input().split())))
i=0
while True:
    if x-i not in p:
        print(x-i)
        exit(0)
    elif x+i not in p:
        print(x+i)
        exit(0)
    i+=1

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    X,N = LMIIS()
    P = LMIIS()

    d = 0
    while True:
        if P.count(X-d) == 0:
            print(X-d)
            return
        elif P.count(X+d) == 0:
            print(X+d)
            return
        d += 1
        


    
main()

Solution (Python):
import sys

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

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

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

i=1
while True:
    if not x-i in P:
        print(x-i)
        break

    if not x+i in P:
        print(x+i)
        break

    i+=1

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

i_max = 101
i_min = 0

for i in range(x, 101):
    if i not in p:
        i_max = i
        break

for i in range(x, 0, -1):
    if i not in p:
        i_min = i
        break

if x - i_min <= i_max - x:
    print(i_min)
else:
    print(i_max)

Solution (Python):
import sys
x,n=map(int,input().split())
a=list(map(int,input().split()))
tmp=0
while True:
    if x-tmp not in a: print(x-tmp);sys.exit()
    elif x+tmp not in a: print(x+tmp);sys.exit()
    tmp+=1

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

dif = 10**18
for d in range(1000):
    tmp = X - d
    if not tmp in P:
        print(tmp)
        exit()
    tmp = X + d
    if not tmp in P:
        print(tmp)
        exit()

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

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

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

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

Solution (Python):

import sys


def solve(X: int, N: int, p: "List[int]"):
    return min(filter(lambda x: x not in p, range(-1, 102)),
               key=lambda x: (abs(X-x), x))



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

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X, N = lr()
P = set(lr())
flag = True
answer = X
while answer in P:
    if flag:
        diff = abs(X - answer)
        answer = X - diff - 1
        flag = False
    else:
        diff = abs(X - answer)
        answer = X + diff
        flag = True

print(answer)

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

i=0
while True:
	ans_n=X-i
	if ans_n not in p_ls:
		print(ans_n)
		break
	
	ans_p=X+i
	if ans_p not in p_ls:
		print(ans_p)
		break
	
	i+=1

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue



sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7


ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    x, n = ns()
    p = na()

    set_p = set(p)

    res = -1

    for i in range(101):
        l = x + i
        s = x - i
        if s not in set_p:
            res = s
            break
        if l not in set_p:
            res = l
            break


    print(res)


if __name__ == '__main__':
    main()

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    X, N = Scanner.map_int()
    P = Scanner.map_int()
    if N == 0:
        print(X)
        return
    t = INF
    for i in range(-1, 102):
        if i in P:
            continue
        t = min(t, abs(i - X))
    if X - t in P:
        print(X + t)
    else:
        print(X - t)


def main():
    
    
    
    
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
target = X
for i in range(1000):
    target = X - i
    if target not in P:
        break
    target = X + i
    if target not in P:
        break
print(target)

Solution (Python):
X,N=map(int,input().split())
d=[0]*201
P=list(map(int,input().split()))
for p in P:
    d[p]=1
a=X
for i in range(101):
    if d[X-i]==0:
        a=X-i
        break
    elif d[X+i]==0:
        a=X+i
        break
print(a)

Solution (Python):
candidates = {i for i in range(-1, 102)}
X, N = map(int, input().split())
P = set(map(int, input().split()))
diff = float('inf')
ans = -100
for x in candidates - P:
    if abs(x - X) < diff:
        diff = abs(x - X)
        ans = x
print(ans)

Solution (Python):
X, N = map(int, input().split())
P = set(map(int, input().split()))
d = 0
while True:
    x = X-d
    if x not in P: break

    x = X+d
    if x not in P: break

    d += 1

print(x)

Solution (Python):
def main():
    x, n = map(int, input().split())
    P = list(map(int, input().split()))
    m = x
    M = x
    if len(P) == 0:
        print(x)
        exit()
    if not x in P:
        print(x)
        exit()

    while True:
        m -= 1
        M += 1
        if not m in P:
            print(m)
            exit()
        if not M in P:
            print(M)
            exit()



if __name__ == "__main__":
    main()

Solution (Python):
x, n = map(int, input().split())
l = list(map(int, input().split()))
vis = [0] * 103
for i in l: vis[i] = 1
mn = 9999
ans = -1
for i in range(103):
    if vis[i] == 0:
        if abs(x - i) < mn:
            mn = x - i
            ans = i
print(ans)

Solution (Python):
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    x, n = map(int, input().split())
    a = set(map(int, input().split()))
    a = sorted(set([i for i in range(102)]) - a)
    s = inf
    for i in a:
        s = min(s, abs(x - i))

    for i in a:
        if abs(x - i) == s:
            print(i)
            return
main()