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

if n==0:

  print(x)

else:

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

  dic={}

  for i in p:

    d=abs(i-x)

    if d in dic:

      dic[d].append(i)

    else:

      dic[d]=[i]

  sortdic = sorted(list(dic.items()), key=lambda x:x[0])

  chk=0

  ans=-1

  for k,v in sortdic:

    if chk==k:

      if chk!=0 and len(v)!=2:

        if v[0]>x:

          ans=x-k

        else:

          ans=x+k

        break

    else:

      ans=x-chk

      break

    chk+=1

  if ans==-1:

    ans=x-chk

  print(ans)
x,y=list(map(int,input().split()))

if y==0:

  print(x)

  exit()

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

for i in range(200):

  if not x-i in p:

    print((x-i))

    exit()

  if not x+i in p:

    print((x+i))

    exit()
x, n = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    dic = {}
    for i in p:
        d = abs(i - x)
        if d in dic:
            dic[d].append(i)
        else:
            dic[d] = [i]
    sortdic = sorted(list(dic.items()), key=lambda x: x[0])
    chk = 0
    ans = -1
    for k, v in sortdic:
        if chk == k:
            if chk != 0 and len(v) != 2:
                if v[0] > x:
                    ans = x - k
                else:
                    ans = x + k
                break
        else:
            ans = x - chk
            break
        chk += 1
    if ans == -1:
        ans = x - chk
    print(ans)

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

-x, n = list(map(int, input().split())) -if n == 0: +x, y = list(map(int, input().split())) +if y == 0: -else: -    p = list(map(int, input().split())) -    dic = {} -    for i in p: -        d = abs(i - x) -        if d in dic: -            dic[d].append(i) -        else: -            dic[d] = [i] -    sortdic = sorted(list(dic.items()), key=lambda x: x[0]) -    chk = 0 -    ans = -1 -    for k, v in sortdic: -        if chk == k: -            if chk != 0 and len(v) != 2: -                if v[0] > x: -                    ans = x - k -                else: -                    ans = x + k -                break -        else: -            ans = x - chk -            break -        chk += 1 -    if ans == -1: -        ans = x - chk -    print(ans) +    exit() +p = list(map(int, input().split())) +for i in range(200): +    if not x - i in p: +        print((x - i)) +        exit() +    if not x + i in p: +        print((x + i)) +        exit()