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:
    p = list(map(int,input().split()))
else:
  print(x)
  exit()


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

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,n=MI()
lis=LI()
for i in range(500):
    l=x-i
    u=x+i
    if not l in lis:
        print(l)
        sys.exit()
    elif not u in lis:
        print(u)
        sys.exit()

Solution (Python):
import bisect
x, n = map(int,input().split())
p = list(map(int,input().split()))
if n == 0:
	print(x)
	exit()
p.sort()
a = bisect.bisect_left(p, x)
a = p[a]
cnt = 0
while True:
	if not a-cnt in p:
		ans = a-cnt
		break
	if not a+cnt in p:
		ans = a+cnt
		break
	cnt += 1
print(ans)

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

notInc = [i for i in range(-1, 102) if i not in xSet]
print(sorted(notInc, key = lambda i : abs(i - x))[0])

Solution (Python):
M,N = map(int,input().rstrip().split(" "))
if N != 0:
    A = set(map(int,input().rstrip().split(" ")))
    ans = -100
    sa = 10 ** 5
    for i in range(-1,102):
        if not i in A:
            if sa > abs(M - i):
                sa = abs(M - i)
                ans = i
    print(ans)
else:
    print(M)

Solution (Python):
def solve(x, n, p_list):
    diff_min = 101
    res = 0
    for i in range(102):
        if i not in p_list:
            if abs(x - i) < diff_min:
                diff_min = abs(x - i)
                res = i
    return res


def main():
    x, n = map(int, input().split())
    p_list = list(map(int, input().split()))
    res = solve(x, n, p_list)
    print(res)


def test():
    assert solve(6, 5, [4, 7, 10, 6, 5]) == 8
    assert solve(10, 5, [4, 7, 10, 6, 5]) == 9
    assert solve(100, 0, []) == 100


if __name__ == "__main__":
    test()
    main()

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

nearest = 0
distance = 100
for x in range(0, 101 + 1):
	if x not in p_set and distance > abs(x - X):
		nearest = x
		distance = abs(x - X)

print(nearest)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
diff = 100
for i in range(0, 102):
    if i not in p and abs(x-i) < diff:
        ans = i
        diff = abs(x-i)
print(ans)

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

if X not in P:
    print(X)
    exit(0)

for i in range(1, 200):
    if X - i not in P:
        print(X-i)
        exit(0)
    elif X + i not in P:
        print(X+i)
        exit(0)

Solution (Python):
def main():
    integar, length = [int(x) for x in input().split()]
    numbers = {int(x) for x in input().split()}
    for diff in range(101):
        aa = integar - diff
        bb = integar + diff
        if aa not in numbers:
            print(aa)
            return
        elif bb not in numbers:
            print(bb)
            return


if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    x, n = map(int, input().split())
    ans = 0
    p = set(map(int, input().split()))
    for i in range(110):
        if i in p:
            continue
        else:
            if abs(i-x) < abs(ans-x):
                ans = i
    print(ans)


if __name__ == '__main__':
    solve()

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

ans = X
for i in range(200):
    if X-i not in S:
        print(X-i)
        break
    elif X+i not in S:
        print(X+i)
        break

Solution (Python):

import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def solve(X: int, N: int, p: "List[int]"):
    kouho = list((set(v + 1 for v in p) | set(v - 1 for v in p)) - set(p))
    kouho.sort()
    diff = INF
    ans = X
    for v in kouho:
        cdiff = abs(v - X)
        if diff > cdiff:
            diff = cdiff
            ans = v
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    X = int(next(tokens))  
    N = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(X, N, p)


if __name__ == '__main__':
    main()

Solution (Python):
import math
import heapq,bisect
import sys
from collections import deque
from fractions import Fraction
mod=10**9+7
mod1=998244353

import os
import sys
from io import BytesIO, IOBase

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


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

class SegmentTree1:
    def __init__(self, data, default=9999999, func=lambda a, b: min(a , b)):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        if start == stop:
            return self.__getitem__(start)
        stop += 1
        start += self._size
        stop += self._size

        res = self._default
        while start < stop:
            if start & 1:
                res = self._func(res, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res = self._func(res, self.data[stop])
            start >>= 1
            stop >>= 1
        return res

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)


class SegmentTree:
    def __init__(self, data, default=0, func=lambda a, b: a + b):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        if start == stop:
            return self.__getitem__(start)
        stop += 1
        start += self._size
        stop += self._size

        res = self._default
        while start < stop:
            if start & 1:
                res = self._func(res, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res = self._func(res, self.data[stop])
            start >>= 1
            stop >>= 1
        return res

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)

class Factorial:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorials = [1, 1]
        self.invModulos = [0, 1]
        self.invFactorial_ = [1, 1]

    def calc(self, n):
        if n <= -1:
            print("Invalid argument to calculate n!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.factorials):
            return self.factorials[n]
        nextArr = [0] * (n + 1 - len(self.factorials))
        initialI = len(self.factorials)
        prev = self.factorials[-1]
        m = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = prev * i % m
        self.factorials += nextArr
        return self.factorials[n]

    def inv(self, n):
        if n <= -1:
            print("Invalid argument to calculate n^(-1)")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        p = self.MOD
        pi = n % p
        if pi < len(self.invModulos):
            return self.invModulos[pi]
        nextArr = [0] * (n + 1 - len(self.invModulos))
        initialI = len(self.invModulos)
        for i in range(initialI, min(p, n + 1)):
            next = -self.invModulos[p % i] * (p // i) % p
            self.invModulos.append(next)
        return self.invModulos[pi]

    def invFactorial(self, n):
        if n <= -1:
            print("Invalid argument to calculate (n^(-1))!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.invFactorial_):
            return self.invFactorial_[n]
        self.inv(n)  
        nextArr = [0] * (n + 1 - len(self.invFactorial_))
        initialI = len(self.invFactorial_)
        prev = self.invFactorial_[-1]
        p = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
        self.invFactorial_ += nextArr
        return self.invFactorial_[n]


class Combination:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorial = Factorial(MOD)

    def ncr(self, n, k):
        if k < 0 or n < k:
            return 0
        k = min(k, n - k)
        f = self.factorial
        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
    if a == 1 or n == 0:
        return 1
    if n % 2 == 0:
        s = powm(a, n // 2, m)
        return s * s % m
    else:
        return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
    zipped_pairs = zip(list2, list1)

    z = [x for _, x in sorted(zipped_pairs)]

    return z

def product(l):
    por=1
    for i in range(len(l)):
        por*=l[i]
    return por

def binarySearchCount(arr, n, key):
    left = 0
    right = n - 1

    count = 0

    while (left <= right):
        mid = int((right + left) / 2)

        
        
        if (arr[mid] <= key):

            
            
            
            count = mid + 1
            left = mid + 1

        
        else:
            right = mid - 1

    return count

def countdig(n):
    c=0
    while(n>0):
        n//=10
        c+=1
    return c
def countGreater(arr, n, k):
    l = 0
    r = n - 1

    
    
    leftGreater = n

    
    while (l <= r):
        m = int(l + (r - l) / 2)

        
        
        if (arr[m] > k):
            leftGreater = m
            r = m - 1

        
        
        else:
            l = m + 1

    
    
    return (n - leftGreater)

x,n=map(int,input().split())
l=[]
if n!=0:
    l=list(map(int,input().split()))
l=set(l)
mi=999999999999999999999999
ans=0
for i in range(-200,201):
    if i not in l:
        if abs(i-x)<mi:
            mi=abs(i-x)
            ans=i
print(ans)

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

Solution (Python):

x, n, *p = map(int, open(0).read().split())
r = [i for i in range(102) if i not in p]
print(sorted(r, key = lambda y: abs(x - y))[0])

Solution (Python):
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
lis = list(map(int,input().split()))
ans = 100000000000
num = 0
for i in range(102):
    if i not in lis:
        if ans > abs(i-x):
            ans = abs(i-x)
            num = i
print(num)

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

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

Solution (Python):



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

x,n = mp()
p = lmp()
for i in range(200):
    if x - i not in p:
        print(x-i)
        exit()
    elif x + i not in p:
        print(x + i)
        exit()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, N = MAP()
p = LIST()

s = set(p)

mi = INF
ans = None
for i in range(-1, 110):
	if i in s:
		continue
	if abs(X-i) < mi:
		mi = abs(X-i)
		ans = i
print(ans)

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

temp=0
if n==0:
    print(x)
    exit()
P=list(map(int,input().split())) 
   
while True:
    if not x-temp in P:
        print(x-temp)
        exit()
    if not x+temp in P:
        print(x+temp)
        exit()
    temp+=1

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

if x not in plst:
    print(x)
    exit()
minus = x
plus = x
while 1:
    minus -= 1
    if minus not in plst:
        print(minus)
        exit()
    plus += 1
    if plus not in plst:
        print(plus)
        exit()

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


def main():
    X, N = map(int, readline().rstrip().split())
    P = set(map(int, readline().rstrip().split()))

    for i in range(200):
        if X - i not in P:
            print(X - i)
            return
        if X + i not in P:
            print(X + i)
            return


if __name__ == '__main__':
    main()

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


ans = 0
check = 100000000000000000000000
for i in range(-100,201):
    if i in p:pass
    else:
        if check > abs(x-i):
            ans = i
            check = abs(x-i)

print(ans)

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction

sys.setrecursionlimit(int(pow(10,6)))


mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]



x,n=l()
p=l()
m=100000000
idx=0
for i in range(-100,201):
    if i not in p:
        if(abs(x-i)<m):
            m=abs(x-i)
            idx=i
print(idx)

Solution (Python):
X, N = map(int, input().split())
P = set(map(int, input().split()))
ans = 0
for i in range(1000):
    if not X-i in P:
        ans = X-i
        break
    if 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()))
s = set(p)
d = 10**5

for i in range(102):
    if i not in s:
        if abs(x-i) < d:
            ans = i
            d = abs(x-i)
print(ans)

Solution (Python):
import bisect
x,n=map(int,input().split())
p = sorted(map(int,input().split()))
i = 0
judge = 0

while judge != 1:
    if x-i not in p:
        ans = x-i
        judge = 1
        break
    if x+i not in p:
        ans = x+i
        judge = 1
    i += 1

print(ans)

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

    for i in range(200):
        a = x - i
        if a not in dat:
            print(a)
            break
        a = x + i
        if a not in dat:
            print(a)
            break

Solution (Python):
from sys import exit

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

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

for i in range(10000000):
  f = True
  if x-i in p:
    f = False
  if f:
    print(x-i)
    exit()
  if x+i in p:
    continue
  print(x+i)
  exit()

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

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

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

maxP = 0
minP = 0

setP = set(P)

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

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  x,n=LI()
  l=LI()

  sa=inf
  ans=inf
  for i in range(-10,200):
    if i in l:
      continue

    _sa=abs(x-i)
    if _sa<sa:
      sa=_sa
      ans=i

  return ans


print(main())

Solution (Python):
X,N=map(int,input().split())
if N==0:
    print(X)
else:
    p=list(map(int,input().split()))
    d=set()
    for P in p:
        d.add(P)
    ans=0
    dmin=100
    for i in range(200):
        if i not in d:
            if abs(X-i)<dmin:
                dmin=abs(X-i)
                ans=i
    print(ans)

Solution (Python):
x,n=map(int,input().split())
ar=[int(i) for i in input().split()]
arr=[i for i in range(0,1000) if i not in ar]
arr.sort()
mini=10000000
for i in arr:
    if abs(i-x)<mini:
        mini=abs(i-x)
        ans=i 
print(ans)

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

lim = max(X, 100 - X)
for i in range(lim + 1):
    if X-i not in ps:
        print(X-i)
        exit()

    if X+i not in ps:
        print(X+i)
        exit()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, N = MAP()
P = LIST()

P.sort()




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

Solution (Python):
X, N, *P = map(int, open(0).read().split())

p = set(P)
diff = 100
ans = 0
for i in reversed(range(-1, 105)):
    if i not in p and abs(i - X) <= diff:
        ans = i
        diff = abs(i - X)
        
print(ans)

Solution (Python):
def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 10**18
    tmp = abs(ans  - n)
    p = set(p)
    for i in range(-1000, 1001):
        if i in p:
            continue
        buf = abs(i - x)
        if buf < tmp:
            ans = i
            tmp = buf
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    import sys
    X,N=list(map(int,sys.stdin.readline().split()))
    P=list(map(int,sys.stdin.readline().split()))
    if not P:
        print(X)
        return
        
    P.sort()
    diff=10**5
    cand=0
    for i in range(min(X,min(P))-1,max(X,max(P))+2):
        if i not in P:
            d=abs(X-i)
            if d<diff:
                diff=d
                cand=i
    print(cand)


main()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

x,n = iim()
p = set(iil())
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):
X,N = map(int,input().split())
*P, = map(int,input().split())

d = 200
ans = 0
for i in range(102):
    if i in P: continue
    if d > abs(X-i):
        d = abs(X-i)
        ans = i
print(ans)

Solution (Python):
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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


def main():
	X, N = getlist()
	P = getlist()
	P = sorted(P)
	ans = None
	dif = INF
	for i in range(102):
		if not (i in P):
			if abs(X - i) < dif:
				ans = i
				dif = abs(X - i)

	print(ans)

if __name__ == '__main__':
	main()

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

ret = 0
diff = 10 ** 9

if n == 0:
    s = input()
    print(x)
    exit()
else:
    p = set(list(map(int, input().split())))
    for i in range(102):
        if i in p:
            continue
        else:
            tmp_d = abs(x - i)
            if diff > tmp_d:
                ret = i
                diff = tmp_d

print(ret)

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

X, N = ri_()
p = ri_()
d = 1000
ans = 1000
for i in range(-500, 501):
    f = 1
    for pi in p:
        if i == pi:
            f = 0
    if f == 1 and d > abs(X - i):
        d = abs(X - i)
        ans = i
print(ans)

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

for i in range(10**9):
    if (X-i) in A:
        pass
    else:
        print(X-i)
        exit()
    if (X+i) in A:
        pass
    else:
        print(X+i)
        exit()

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

x,n,*p = map(int,read().split())

p = set(p)

v = x
for i in range(1000):
    if v+i not in p:
        break
v = v+i

w = x
for i in range(1000):
    if w-i not in p:
        break
w = w-i

if abs(v-x) < abs(w-x):
    print(v)
else:
    print(w)

Solution (Python):
x, n = map(int,input().split())
if n>0:
    li = list(map(int, input().split()))
    y1 = x
    y2 = x
    while True:
        if y1 not in li:
            print(y1)
            break
        elif y2 not in li:
            print(y2)
            break
        else:
            y1-= 1
            y2 += 1
else:
    print(x)

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

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

flag = True
i=1
while flag:
    if not x-i in plis:
        print(x-i)
        exit()
    elif not x+i in plis:
        print(x+i)
        exit()
    else:
        i += 1

Solution (Python):
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
p = [int(x) for x in input().split()]
p.sort()
q = len(p)
index = 0
ans = -1
count = 101
for i in range(0, 102):
  if index < q and p[index] == i:
    index += 1
    continue
  if count > abs(i-x):
    count = abs(i-x)
    ans = i
print(ans)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    x,n=map(int,readline().split())
    a=list(map(int,readline().split()))
    s=set(a)

    ans_1=x
    ans_2=x
    while True:
        if ans_1 not in s:
            print(ans_1)
            break
        elif ans_2 not in s:
            print(ans_2)
            break
        else:
            ans_1-=1
            ans_2+=1

if __name__=="__main__":
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, n = map(int, readline().split())
    p = list(map(int, readline().split()))

    ans = 1000000

    for i in range(101, -100, -1):
        if i in p:
            continue
        else:
            diff = abs(x-i)
            if diff <= abs(x-ans):
                ans = i
    print(ans)

if __name__ == '__main__':
    main()