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

if  N == 0:

  print(X)

  exit()

array = sorted(list(map(int,input().split())))

if not X in array:

  print(X)

  exit()  

else:

  for i in range(1,200):

    X_plus = X + i

    X_pull = X - i

    if not X_pull in array:

      print(X_pull)

      exit()

    if not X_plus in array:

      print(X_plus)

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

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



Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの

ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法

print(ans)
X, N = list(map(int, input().split()))
if N == 0:
    print(X)
    exit()
array = sorted(list(map(int, input().split())))
if not X in array:
    print(X)
    exit()
else:
    for i in range(1, 200):
        X_plus = X + i
        X_pull = X - i
        if not X_pull in array:
            print(X_pull)
            exit()
        if not X_plus in array:
            print(X_plus)
            exit()

X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

-if N == 0: -    print(X) -    exit() -array = sorted(list(map(int, input().split()))) -if not X in array: -    print(X) -    exit() -else: -    for i in range(1, 200): -        X_plus = X + i -        X_pull = X - i -        if not X_pull in array: -            print(X_pull) -            exit() -        if not X_plus in array: -            print(X_plus) -            exit() +P = list(map(int, input().split())) +Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの +ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法 +print(ans)