{-# LANGUAGE TypeApplications #-}

import Data.List

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let [x, n] = map (read @Int) $ words l1
      ps = map (read @Int) $ words l2
  print $ f x ps

f x ps
  | not $ null eq = x
  | null lt = y2
  | null gt = y1
  | abs (y1 - x) <= abs (y2 - x) = y1
  | otherwise = y2
  where
    (lt, ge) = span (<x) $ filter (`notElem` ps) $ sort [0..101]
    (eq, gt) = span (==x) ge
    y1 = last lt
    y2 = head gt
