#array to get nearest values

A, B = list(map(int, input().split()))

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

for d in range(A + 1):

    for s in [-1, +1]:

        x = A + s * d

        if p.count(x) == 0:



             print(x)



             exit(0)
# inpute integer (x) along with integer sequence (n)

# finding the integer nearest to x within the given range 100

# no time i have to submit

x, n = list(map(int, input().split()))  # take input from the user

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



for i in range(101):  # loop through the range

    length = x - i

    result = x + i

    if length not in P:

        print(length)

        break

    elif result not in P:

        print(result)

        break



# array to get nearest values
A, B = list(map(int, input().split()))
p = list(map(int, input().split()))
for d in range(A + 1):
    for s in [-1, +1]:
        x = A + s * d
        if p.count(x) == 0:
            print(x)
            exit(0)

# inpute integer (x) along with integer sequence (n)
# finding the integer nearest to x within the given range 100
# no time i have to submit
x, n = list(map(int, input().split()))  # take input from the user
P = list(map(int, input().split()))
for i in range(101):  # loop through the range
    length = x - i
    result = x + i
    if length not in P:
        print(length)
        break
    elif result not in P:
        print(result)
        break

-# array to get nearest values -A, B = list(map(int, input().split())) -p = list(map(int, input().split())) -for d in range(A + 1): -    for s in [-1, +1]: -        x = A + s * d -        if p.count(x) == 0: -            print(x) -            exit(0) +# inpute integer (x) along with integer sequence (n) +# finding the integer nearest to x within the given range 100 +# no time i have to submit +x, n = list(map(int, input().split()))  # take input from the user +P = list(map(int, input().split())) +for i in range(101):  # loop through the range +    length = x - i +    result = x + i +    if length not in P: +        print(length) +        break +    elif result not in P: +        print(result) +        break