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

if n == 0:

    print(x)

    exit()



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



for d in range(x + 2):

	for s in [-1, 1]:

		a = x + s * d

		if a not in p:

			print(a)

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

if n == 0:

    print(x)

    exit()

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



for d in range(x + 2):

	if x - d not in p:

		print((x-d))

		exit()

	if x + d not in p:

		print((x+d))

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

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

-    for s in [-1, 1]: -        a = x + s * d -        if a not in p: -            print(a) -            exit() +    if x - d not in p: +        print((x - d)) +        exit() +    if x + d not in p: +        print((x + d)) +        exit()