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

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





for i in range(200):

    if x - i not in p:

        print((x - i))

        break

    if x + i not in p:

        print((x + i))

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

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





for i in range(101):

    if x - i not in p:

        print((x - i))

        break

    if x + i not in p:

        print((x + i))

        break
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(200):
    if x - i not in p:
        print((x - i))
        break
    if x + i not in p:
        print((x + i))
        break

x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(101):
    if x - i not in p:
        print((x - i))
        break
    if x + i not in p:
        print((x + i))
        break

-for i in range(200): +for i in range(101):