Problem:
 Score : 300 points    Problem Statement Given are an integer X and an integer sequence of length N : p_1, \ldots, p_N .  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X , that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.      Constraints  1 \leq X \leq 100  0 \leq N \leq 100  1 \leq p_i \leq 100  p_1, \ldots, p_N are all distinct.  All values in input are integers.         Input Input is given from Standard Input in the following format:  X  N  p_1  ...  p_N       Output Print the answer.        Sample Input 1 6 5
4 7 10 6 5      Sample Output 1 8  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the one nearest to 6 is 8 .       Sample Input 2 10 5
4 7 10 6 5      Sample Output 2 9  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the ones nearest to 10 are 9 and 11 . We should print the smaller one, 9 .       Sample Input 3 100 0      Sample Output 3 100  When N = 0 , the second line in the input will be empty. Also, as seen here, X itself can be the answer.

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

if x not in p:
    print(x)
else:
    for i in range(100):
        Ans1 = x - i
        Ans2 = x + i
        if Ans1 not in p:
            print(Ans1)
            break
        if Ans2 not in p:
            print(Ans2)
            break

Solution (Python):
import math
x,n  = map(int,input().split())
if n==0:
    print(x)
    exit()
p = [int(i) for i in input().split()]


max_ = max(p)
a= [i for i in range(2*max_+1)]

m=0
for i in p:
    a[i]=100000
min_=100000
for i in a:
    b = abs(i-x)
    if min_ > b:
        min_=b
        m = i
print(m)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = [i for i in range(0, 102)]
z = list(set(p)^set(l))
y = []
for i in z:
    y.append(abs(x-i))
z2 = sorted(y)
ans1 = x-z2[0]
ans2 = x+z2[0]
m = min(ans1, ans2)
M = max(ans1, ans2)
if m in z:
    print(m)
else:
    print(M)

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

for pp in P:
    if abs(pp - X) < p_min_abs:
        p_min_abs = abs(pp - X)
        p_min = pp
print(p_min)

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

for i in range(n+1):
    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())
if N==0:
    print(X)
    exit()
P = set(map(int, input().split()))

Min = float("inf")
ans = int()
for i in range(-1, 102):
    if not i in P:
        if Min > abs(X-i):
            Min = abs(X-i)
            ans = i
print(ans)

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

  min = 1000
  ans = 0
  for i in range(102):
    if abs(x-i)<min and (i in p)==False:
      min = abs(x-i)
      ans = i

  print(ans)

Solution (Python):
import numpy as np
x,n=(int(x) for x in input().split())
p = np.array([int(x) for x in input().split()])

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

Solution (Python):
import sys

a = list(map(int, input().split()))
X = a[0]
N = a[1]

try:
  p = list(map(int, input().split()))
except EOFError:
  print(X)
  sys.exit()

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

Solution (Python):

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

p=sorted([int(x) for x in input().split()])
a=[]
ans=10**9
for i in range(-1,102):
    if i in p:
        pass
    else:
        a.append([i,abs(x-i)])
        ans=min(ans,abs(x-i))
for i in range(len(a)):
    if a[i][1]==ans:
        print(a[i][0])
        sys.exit()

Solution (Python):
para_line = list(map(int,input().split(' ')))
if(para_line[1]):
    input_line = list(map(int,input().split(' ')))

ans = para_line[0]
if(para_line[1]):
    for i in range(100):
        if(para_line[0]-i not in input_line):
            ans = para_line[0]-i
            break
        if(para_line[0]+i not in input_line):
            ans = para_line[0]+i
            break
print(ans)

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

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

p_set = set(p_list)
min_p = min(p_list)
max_p = max(p_list)

compare_X = X
min_d = 100000
min_d_i = compare_X

while True:
    if compare_X not in p_set:
        d = abs(X - compare_X)
        min_d = min(min_d, d)
        if min_d == d:
            min_d_i = compare_X

    if compare_X > max_p:
        break

    compare_X += 1

compare_X = X


while True:
    if compare_X not in p_set:
        d = abs(X - compare_X)
        min_d = min(min_d, d)
        if min_d == d:
            min_d_i = compare_X

    if compare_X < min_p:
        break

    compare_X -= 1


print(min_d_i)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))
all = list(range(0, 102))
diff = []

for i in p:
    all.remove(i)

for j in all:
    diff.append(abs(x-j))

diff_min = min(diff)
num_min = diff.index(diff_min)
ans = all[num_min]

print(ans)

Solution (Python):
def around_nums(x):
    i = 1

    while(True):
        yield x
        yield x - i
        yield x + i
        i += 1

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

nums = list(map(int, temp.split()))
for n in around_nums(x):
    if not n in nums:
        print(n)
        break

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
dist=1000000
for i in range(110):
    i-=2
    if i in p:
        continue
    if abs(i-x) < dist:
        dist = abs(i-x)
        ans = i

print(ans)

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

ans = 10 ** 9
num = 10 ** 9
a = [0] * 200
for i in range(len(p)):
    a[p[i]] = 1

for i in range(110):
    if a[i] == 1:
        continue

    if ans > abs(i - x):
        num = i
        ans = abs(i - x)


if abs(x - (-1)) <= abs(num-x):
    num = -1
print(num)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans1 = 999999
for i in range(101,-1,-1):
    if i not in p:
        if abs(x - i) <= abs(x - ans1):
            ans1 = i
print(ans1)

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

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

    p.sort()
    trgt = x
    roop_flg = True
    a = 1
    while roop_flg:
        if trgt not in p:
            break
        else:
            if a > 0:
                trgt = trgt -a
                a = -(a+1)

            else:
                trgt = trgt -a
                a = -(a-1)


    print(trgt)

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

if(not X in p_list):
    print(X)
else:
    for i in range(100):
        if(not X-i in p_list):
            print(X-i)
            break
        elif(not X+i in p_list):
            print(X+i)
            break

Solution (Python):
X, N = map(int, input().split())
p_lst = list(map(int, input().split()))
o_lst = list(range(0,102))
lst = list(set(p_lst) ^ set(o_lst))

if X in lst:
    print(X)
else:
    for i in range(100):
        if X - i in lst:
            print(X-i)
            break
        if X + i in lst:
            print(X+i)
            break

Solution (Python):
import sys


def main():
    X, N = list(map(int, input().split()))
    ans = 999
    dis = 999
    if N == 0:
        print(X)
        sys.exit()
    P = list(map(int, input().split()))
    for i in range(0, 102):
        if i not in P:
            if dis > abs(i - X):
                dis = abs(i - X)
                ans = i
    print(ans)


if __name__ == '__main__':
    main()

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

ans = 10**18

for i in range(-100, 200):
    if i in P:
        continue
    if abs(X - i) < abs(X - ans):
        ans = i
    if abs(X - i) == abs(X - ans):
        if i < ans:
            ans = i

print(ans)

Solution (Python):
import sys
X, N = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
if X not in P:
    print(X)
    sys.exit()

for i in range(55):
    low = X - i
    if low not in P:
        print(low)
        break
    high = X + i
    if high not in P:
        print(high)
        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(101):
    if (X+i not in P) and (X-i not in P):
      print(min(X+i, X-i))
      exit()
    elif (X+i not in P):
      print(X+i)
      exit()
    elif (X-i not in P):
      print(X-i)
      exit()
    else:
      X+=0

Solution (Python):
x,n = map(int, input().split())
p = [int(i) for i in input().split()]
ans = 0
if x in p:
    p.sort()
    for i,v in enumerate(p):
        if v == x:
            break
    j = 1
    while True:
        if i-j < 0 or v-j != p[i-j]:
            ans = v-j
            break
        if i+j > n-1 or v+j != p[i+j]:
            ans = v+j
            break
        j += 1
else:
    ans = x
print(ans)

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

if n==0:
    print(x)
else:
    if x in ls:
        ls.sort()
        x_idx = ls.index(x)
        pos_search = x + 1
        ans_1 = ls[-1]+1
        ans_2 = ls[0]-1
        for i in ls[x_idx+1:]:
            if i == pos_search:
                pass
            else:
                ans_1 = pos_search
                break
            pos_search+=1
        nega_ls = ls[:x_idx]
        nega_ls.reverse()
        nega_search = x - 1
        for i in nega_ls:
            if i == nega_search:
                pass
            else:
                ans_2 = nega_search
                break
            nega_search-=1
        if abs(ans_2-x) <= abs(ans_1-x):
            print(ans_2)
        else:
            print(ans_1)
    else:
        print(x)

Solution (Python):
X,N = map(int,input().split())
P = [int(i) for i in input().split()]
ans = 100000
flag = False
for i in range(-1,102):
    if i in P:
        pass
    else:
        if abs(X - ans) > abs(X-i):
            flag = True
            ans = i
print(ans)

Solution (Python):
x, n = map(int,input().split())
p = list(map(int,input().split()))
l=[]
judge=[]
for i in range(120):
    l.append(i)
    l.append(-1*i)
for i in range(n):
    l.remove(p[i])
for i in range(len(l)):
    judge.append((l[i]-x)**2)
judge.sort()
if x - judge[0]**0.5 in l :
    print(int(x - judge[0]**0.5))
else:
    print(int(x + judge[0]**0.5))

Solution (Python):


def find(l, r, lst):

    if (l - 1) not in lst:
        return (l - 1)
    
    if (r + 1) not in lst:
        return (r + 1)
    
    return find(l - 1, r + 1, lst)



def main():
    
    x, n = map(int, input().split())
    lst = list(map(int, input().split()))

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

    if x not in lst:
        print(x)
        exit(0)
    
    print(find(x, x, lst))




if __name__ == '__main__':
    main()

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

for i in range(100):
    u_flg = False
    l_flg = False

    x_u=x+i
    x_l=x-i
    for p in P:
        if x_u == p:
            u_flg = True
        if x_l == p:
            l_flg = True

    if u_flg == False and l_flg == False:
        print(min(x_u,x_l))
        break
    elif u_flg == False:
        print(x_u)
        break
    elif l_flg == False:
        print(x_l)
        break

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

n_ans = 0
sa = 200
for k in range(0,102,1):
    if (k in p):
        continue
    if(abs(k-X) < sa):
        n_ans = k
        sa = abs(k-X)
    else:
        break
print(n_ans)

Solution (Python):
X,N = list(map(int,input().split()))
if N == 0:
  print(X)
  exit()
P = sorted(list(map(int,input().split())))
ans1 = P[0] - 1
ans2 = P[-1] + 1
isx = 0
for i in range(1,N):
  if (P[i]-X) > 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[i-1] != (P[i]-1):
    ans1 = P[i] -1
  if P[i] == X:
    isx = 1
    break

for i in range(1,N+1):
  if (P[-i]-X) < 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[-i+1] != (P[-i]+1):
    ans2 = P[-i] + 1
  if P[-i] == X:
    isx = 1
    break

if not isx:
  print(X)
  exit()

aa1 = abs(X-ans1)
aa2 = abs(X-ans2)
if aa1 == aa2:
  print(ans1)
elif aa1 > aa2:
  print(ans2)
else:
  print(ans1)

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


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

Solution (Python):
x, n = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0]*200
for i in range(200):
    b[i] = i
for i in range(len(a)):
    b.remove(a[i])
min = 1000000
ans=0
for i in range(len(b)):
    dist = abs(b[i] - x)
    if min > dist:
        min = dist
        ans = b[i]
print(ans)

Solution (Python):
R = lambda: map(int, raw_input().split())
X, N = R()
s = set(R())

for i in xrange(1000):
    if X - i not in s:
        print X - i
        break
    if X + i not in s:
        print X + i
        break

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

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


a = list(range(-1,102))

for i in lis:
    a.remove(i)

ans = 10000    
tans = 0
for j in a:
    tmp = abs(j-x)
    if tmp < ans:
        tans = j
        ans = tmp
        
print(tans)

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

over = x
under = x

while True:
  if over in p and under in p:
    over +=1
    under -=1
    continue
  elif under in p:
    ans = over
    break
  else:
    ans = under
    break
    
print(ans)

Solution (Python):

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

memo1 = [0]*100
memo2 = [0]*100
a,b = 1000,1000
if n == 0:
    print(x)
    exit()
for i in range(100):
    memo1[i] = abs(i-x)
    memo2[i] = abs(i+x)
    if memo1[i] not in p:
        a = memo1[i]
        i1 = i
        break
    elif memo2[i] not in p:
        b = memo2[i]
        i2 = i
        break
if a<=b:
    print(a)
else:
    print(b)

Solution (Python):
import sys

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


for i in range(x+1):
    s = x-i
    t = x+i
    
    if s in p and t in p:
        continue
    
    elif s in p and t not in p :
        print(t)
        sys.exit()
    
    else :
        print(s)
        sys.exit()

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

if x not in dic:
    print(x)
else:
    for i in range(1, 101):
        a=x-i
        b=x+i
        if a not in dic and b not in dic:
            print(min(a,b))
            exit()
        if a not in dic:
            print(a)
            exit()
        if b not in dic:
            print(b)
            exit()

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

Xm = X
Xp = X
status = True

while status:
    if Xm not in p:
        print(Xm)
        status = False
    elif Xp not in p:
        print(Xp)
        status = False
    Xm -= 1
    Xp += 1

Solution (Python):


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

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

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

result = 0

if X not in P:
  result = X
else:
  diff = 1
  flag = True
  while flag:
    if (X - diff) not in P:
      result = X - diff
      break
    if (X + diff) not in P:
      result = X + diff
      break
    diff += 1
    
print(result)

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

P = list(map(int, input().split()))
candidates = [i for i in range(102)]

ans = 1000
min_diff = 1000
for c in candidates:
    if c in P:
        continue
    diff = abs(X - c)
    if diff < min_diff:
        ans = c
        min_diff = diff

print(ans)

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

for i in range(1, 10**9):
    if x-i not in p:
        print(x-i)
        break
    if x+i not in p:
        print(x+i)
        break

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = 102
for i in range(-100,102):
    if not i in p:
        if abs(i-X) < abs(ans-X):
            ans = i

print(ans)

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=300
for i in range(-100,200):
    if p.count(i)==0:
        if abs(ans-x)>abs(i-x):
            ans=i
print(ans)

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

diffs = dict()
for i in range(100 + 2):
    diffs[i] = abs(x - i)
for p in p_list:
    diffs[p] = float('inf')

min_diff = float('inf')
min_num = float('inf')
for i in range(100 + 2):
    if min_diff > diffs[i]:
        min_diff = diffs[i]
        min_num = i
print(min_num)

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

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    while(1):
        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())
P = list(map(int, input().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())
p = list(map(int, input().split()))

if x in p:
    y = x - 1
    while y in p:
        y -= 1
    z = x + 1
    while z in p:
        z += 1
    
    if(abs(y-x) == abs(z-x)):
        print(y)
    elif(abs(y-x) > abs(z-x)):
        print(z)
    else:
        print(y)
else:
    print(x)

Solution (Python):
X, N = map(int,input().split())
if N==0:
    print(X)
else:
    P = list(map(int,input().split()))
    P.sort()
    Q = [i-1 for i in range(-10,111)]
    for a in P:
        Q.remove(a)
    Q1 = [abs(b - X) for b in Q]
    print(Q[Q1.index(min(Q1))])

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline
    
    
    
    x, n = map(int, input().split())
    
    
    
    
    
    

    if n == 0:
        print(x)
    else:
        P = list(map(int, input().split()))
        P.sort()
        

        if x not in P:
            print(x)
        else:
            xindex = P.index(x)

            for j in range(1,100):
                if xindex - j >= 0:
                    if P[xindex - j] != x-j:
                        print(x-j)
                        break
                else:
                    print(x-j)
                    break
                if xindex + j <= n-1:
                    if P[xindex + j] != x+j:
                        print(x+j)
                        break
                else:
                    print(x+j)
                    break

resolve()

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

a,b=x,x

ans=0
while ans==0:
  if n==0:
    ans=x
  elif x not in lis:
    ans=x
  else:
    a=a-1
    b=b+1
    if a not in lis:
      ans=a
      break
    if b not in lis:
      ans=b

print(ans)

Solution (Python):

from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if n == 0 or x not in p:
        print(x)
    else:
        for i in range(200):
            num1 = x-i
            num2 = x+i
            if num1 not in p and num2 not in p:
                print(min(num1, num2))
                break
            elif num1 not in p:
                print(num1)
                break
            elif num2 not in p:
                print(num2)
                break


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):


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

flag = True
i = 0

while flag:
  if x - i not in num_list:
    ans = x - i
    break
  elif x + i not in num_list:
    ans = x + i
    break
  i += 1

print(ans)

Solution (Python):


import math

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

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

p = sorted(p)

for i in range(100):
    if X-i not in p:
        print(X-i)
        quit()

    if X+i not in p:
        print(X+i)
        quit()

Solution (Python):


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

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

ans = X

for i in range(200):
  temp1 = X - i
  temp2 = X + i
  if not temp1 in P:
    ans = temp1
    break
  elif not temp2 in P:
    ans = temp2
    break

print(ans)

Solution (Python):
X ,N = map(int,input().split())
P = list(map(int,input().split()))
if N == 0:
    print(X)
    exit(0)
A = list(range(0,102))
ans = 0
mins = 100


for a in A:
    if a not in P:
        if abs(a-X) < mins:
            mins = abs(a-X)
if (X - mins) not in P:
    print(X-mins)
else:
    print(X+mins)

Solution (Python):
import sys

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

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

min_d = 1000000

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

for i in range(110):
    if i in p:
        continue
    d = abs(x - i)
    if d < min_d:
        min_d = d
        ans = i

print(ans)

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

ls = sorted(ls)
d = 10**3
ans = 0
for i in range(ls[0]-1,ls[-1]+2):
  if i in ls:
    continue
  if d>abs(i-x):
    d = abs(i-x)
    ans = i
print(ans)

Solution (Python):
x,n=map(int,input().split())
n=list(map(int,input().split()))
n.sort
if(x not in n):
    print(x)
    exit()
finder=n.index(x)
i=1
while(True):
    if(x-i not in n):
        print(x-i)
        exit()
    if(x+i not in n):
        print(x+i)
        exit()
    i=i+1

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

Solution (Python):
import sys

data = sys.stdin
data_list = data.readlines()
data_1 = data_list[0].strip("\n").split(" ")
data_2 = data_list[1].strip("\n").split(" ")
i = 0

if data_1[1] == "0":
  print(data_1[0])
else:
  while True:
    if int(data_1[0]) - i >= 0:
      ans = int(data_1[0]) - i
      if str(ans) not in data_2:
        print(ans)
        break
    ans = int(data_1[0]) + i
    if str(ans) not in data_2:
      print(ans)
      break
    i += 1

Solution (Python):
X, num = [int(i) for i in input().split(" ")]

 
if num == 0:
  print(X)
else:
  l = [int(i) for i in input().split(" ")]
  for i in range(num):
    if X-i not in l:
      print(X-i)
      exit()
    elif X+i not in l:
      print(X+i)
      exit()
  print(X-num)

Solution (Python):
X,N=map(int,input().split())
hazusu=list(map(int,input().split()))
kouho=100
ans=0
for i in reversed(range(-2,102)):
    if i in hazusu:
        continue
    d=abs(X-i)
    if d<=kouho:
        kouho=d
        ans=i
print(ans)

Solution (Python):
from math import *
x,n=map(int,input().split())
p=[]
if n>0:
	p=[int(i) for i in input().split()]
mn=float('inf')
ans=-1
for i in range(-1,102):
	if not i in p:
		if abs(x-i) < mn:
			ans=i
			mn=abs(x-i)
print(ans)

Solution (Python):
X,N=map(int,input().split())
P = list(map(int,input().split()))
value = float('inf')
if(N==0):
    print(X)
    exit()
ans_value= 101
for i in range(0,102):
    if (i not in P):
        if(abs(X-i)<value):
            value=abs(X-i)
            ans_value=i
print(ans_value)

Solution (Python):
lst1 = input().split()
lst2 = input().split()
key = int(lst1[0])
lst = []
for i in range(102):
    lst.append(i)
for i in lst2:
    lst.remove(int(i))
for i in range(len(lst)):
    if lst[i] > key:
        break
if lst[i] - key < key - lst[i-1]:
    print(lst[i])
else:
    print(lst[i-1])

Solution (Python):
import numpy as np

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(-1, 102))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()

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

listP.sort()

minD = 200
val = 0
bef = None
for p in listP:
    if bef == None:
        bef = p
        minD = abs(p-1-x)
        val = p-1
    else:
        if p-1 == bef:
            pass
        else:
            if bef < x < p:
                minD = 0
                val = x
            elif x <= bef:
                if abs(bef+1-x) < minD:
                    minD = abs(bef+1-x)
                    val = bef+1
            else:
                if abs(p-1-x) < minD:
                    minD = abs(p-1-x)
                    val = p-1
        bef = p
if not x in listP:
    val = x
    minD = 0
elif val == 0:
    if abs(0-x) > abs(101-x):
        val = 101
        minD = abs(101-x)
    else:
        val = 0
        minD = abs(0-x)
elif bef!=None and abs(bef+1-x) < minD:
    val = bef+1

print(val)

Solution (Python):
X, N = [int(_) for _ in input().split()]
pn = [int(_) for _ in input().split()]
pn.sort()

pn_bar = [int(_) for _ in range(-100*2-1,100*2+1) if (_ not in pn)]




now_min = 10000
ans = 10000
for i in pn_bar:
    delta = abs(i - X)
    if(delta < now_min):
        ans = i
        now_min = delta
        
print(ans)

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

    x_up = x
    x_down = x

    while True:
        if x_down not in p:
            print(x_down)
            break
        elif x_up not in p:
            print(x_up)
            break

        x_up += 1
        x_down -= 1

if __name__ == "__main__":
    main()

Solution (Python):

X, N = map(int, input().split())
A = list(map(int, input().split()))
dct = {i: [] for i in range(101)}
for i in A:
    num = abs(X - i)
    dct[num].append(i)
for k,v in dct.items():
    if (k == 0):
        if (len(v) == 0):
            print(X)
            break
    elif (len(v) == 0):
        if (X >= k):
            print(X - k)
            break
        else:
            print(k - X)
            break
    elif (len(v) == 1):
        if (X - k == v[0]):
            print(X + k)
            break
        else:
            print(X - k)
            break

Solution (Python):
XN = input().split()
X = int(XN[0])
N = int(XN[1])
if N == 0:
    print(X)
    exit(0)
P = input().split()
pp=[int(s) for s in P]
if X not in pp:
    print(X)
    exit(0)

ans = []
flag = False
for i in range(N):
    if X - i - 1 not in pp:
        print(X - i - 1)
        exit(0)
    if X + i +1 not in pp:
        print(X + i + 1)
        exit(0)

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

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

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

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

p.sort()
q = [i for i in range(0, 102) if i not in p]

diff = [0] * len(q)
for i in range(len(q)):
      diff[i] = abs(q[i] - x)

index = diff.index(min(diff))
print(q[index])

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

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


    


for i in range(101):
    if ((x-i) in p) == False:
        print(x-i)
        break
    elif ((x+i) in p) ==False:
        print(x+i)
        break

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

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

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

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

ans = 999
for i in range(-1, 102):
    if not i in p_li:
        tmp = i

        if abs(x - ans) > abs(x - tmp):
            ans = i

print(ans)

Solution (Python):
import numpy as np

x, n = map(int, input().split())
arr = {i for i in range(102)}

for i in input().split():
    arr.remove(int(i))

arr = list(arr)

idx = np.abs(np.asarray(arr) - x).argmin()

print(arr[idx])

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

n_P = []

for i in range(1, 100):
    if i not in P:
        n_P.append(i)

n_P.append(0)
n_P.append(101)

n_P.sort()
INF = 10 ** 9
diff = INF
ans = INF

for p in n_P:
    if abs(X-p) < diff:
        diff = abs(X-p)
        ans = p

print(ans)

Solution (Python):
import os
import numpy as np

if os.path.exists('input.txt'):
    test_mode = True
else:
    test_mode = False

if test_mode:
    f = open('input.txt')
    
def get_input():
    if test_mode:
        return f.readline().rstrip()
    else:
        return input().rstrip()

def int_list(l):
    for i in range(len(l)):
        l[i] = int(l[i])
    
input_line = get_input().split()
X = int(input_line[0])
N = int(input_line[1])
p = get_input().split()
int_list(p)

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

if test_mode:
    f.close()

Solution (Python):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    arr = list(map(int, input().split()))
    
    target = x
    count = 1
    while True:
        if target not in arr:
            print(target)
            break
        if count % 2 != 0:
            target -= count
        else:
            target += count
        count += 1

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

P = []

for i in range(101):
    P.append(i)

for j in range(len(P)):
    if P[j] in p:
        P[j] = 101

l = []

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

min = l[0]
ans = 0
sub = 101

for j in range(1, 101):
    if min > l[j]:
        min = l[j]
        ans = j
    elif min == l[j]:
        sub = j

if sub != 101:
    if P[ans] >P[sub]:
        print(P[sub])
    else:
        print(P[ans])
else:
    print(P[ans])