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

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

pss = [i for i in range(-1000, 1000)]

ps = list([i for i in pss if i not in ps])

ans = x



for i, p in enumerate(ps):

    temp = abs(x-p)

    if i == 0:

        mins = temp

        ans = p

    else:

        if mins > temp:

            mins = temp

            ans = p

        elif mins == temp:

            if ans > p:

                ans = p



print(ans)
# -*- coding: utf-8 -*-

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

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



for i in range(0, x+100):

    for j in [-1, 1]:

        temp = x + (i*j)

        if ps.count(temp) == 0:

            ans = temp

            break

    else:

        continue

    break





print(ans)

x, n = list(map(int, input().split()))
ps = list(map(int, input().split()))
pss = [i for i in range(-1000, 1000)]
ps = list([i for i in pss if i not in ps])
ans = x
for i, p in enumerate(ps):
    temp = abs(x - p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p
print(ans)

# -*- coding: utf-8 -*-
x, n = list(map(int, input().split()))
ps = list(map(int, input().split()))
for i in range(0, x + 100):
    for j in [-1, 1]:
        temp = x + (i * j)
        if ps.count(temp) == 0:
            ans = temp
            break
    else:
        continue
    break
print(ans)

+# -*- coding: utf-8 -*- -pss = [i for i in range(-1000, 1000)] -ps = list([i for i in pss if i not in ps]) -ans = x -for i, p in enumerate(ps): -    temp = abs(x - p) -    if i == 0: -        mins = temp -        ans = p +for i in range(0, x + 100): +    for j in [-1, 1]: +        temp = x + (i * j) +        if ps.count(temp) == 0: +            ans = temp +            break -        if mins > temp: -            mins = temp -            ans = p -        elif mins == temp: -            if ans > p: -                ans = p +        continue +    break