import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Control.Arrow

closest x [] = x
closest x [q]
  | x == q = x - 1
  | otherwise = x
closest x nums = sorted2
  where
    sorted = sortOn snd [(q, abs $ x - q) | q <- [x - 101..x + 101], not $ elem q nums]
    s = snd $ head sorted
    sortedFiltered = filter (\x -> s == (snd x)) sorted
    sorted2 = minimum $ map fst sortedFiltered

main = do
  let readInt = fmap (second B.tail) . B.readInt
  [x,n] <- map read . words <$> getLine
  ps <- VU.unfoldrN n readInt <$> B.getLine
  let ans = closest x $ VU.toList ps
  putStrLn $ show ans