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

if n==0:

    print(x)

    exit()

elif n==100:

    if abs(-1-x)<=abs(101-x):

        print((0))

    else:

        print((101))

    exit()

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

num=list(range(0,102))

min_num=1000000000

for i in range(len(List)):

    if num.count(List[i])>=1:

        num.remove(List[i])

for i in range(len(num)):

    if (abs(num[i]-x)<abs(min_num-x)) or (abs(num[i]-x)==abs(min_num-x) and num[i]<min_num):

        min_num=num[i]

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

if n==0:

    print(x)

    exit()

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

ans=list(range(0,102))

min_num=1000

for i in List:

    ans.remove(i)

for i in ans:

    if (abs(i-x)<abs(min_num-x)) or (abs(i-x)==abs(min_num-x) and i<min_num):

        min_num=i

print(min_num)
x, n = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
elif n == 100:
    if abs(-1 - x) <= abs(101 - x):
        print((0))
    else:
        print((101))
    exit()
List = list(map(int, input().split()))
num = list(range(0, 102))
min_num = 1000000000
for i in range(len(List)):
    if num.count(List[i]) >= 1:
        num.remove(List[i])
for i in range(len(num)):
    if (abs(num[i] - x) < abs(min_num - x)) or (
        abs(num[i] - x) == abs(min_num - x) and num[i] < min_num
    ):
        min_num = num[i]
print(min_num)

x, n = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
List = list(map(int, input().split()))
ans = list(range(0, 102))
min_num = 1000
for i in List:
    ans.remove(i)
for i in ans:
    if (abs(i - x) < abs(min_num - x)) or (
        abs(i - x) == abs(min_num - x) and i < min_num
    ):
        min_num = i
print(min_num)

-elif n == 100: -    if abs(-1 - x) <= abs(101 - x): -        print((0)) -    else: -        print((101)) -    exit() -num = list(range(0, 102)) -min_num = 1000000000 -for i in range(len(List)): -    if num.count(List[i]) >= 1: -        num.remove(List[i]) -for i in range(len(num)): -    if (abs(num[i] - x) < abs(min_num - x)) or ( -        abs(num[i] - x) == abs(min_num - x) and num[i] < min_num +ans = list(range(0, 102)) +min_num = 1000 +for i in List: +    ans.remove(i) +for i in ans: +    if (abs(i - x) < abs(min_num - x)) or ( +        abs(i - x) == abs(min_num - x) and i < min_num -        min_num = num[i] +        min_num = i