import Control.Monad
import Data.Function
import Data.Char
import Data.List
import Text.Read
import Text.ParserCombinators.ReadPrec

import qualified Data.ByteString.Char8 as B

newtype Pair a b = Pair { getPair :: (a, b) }

instance (Read a, Read b) => Read (Pair a b) where
  readPrec = Pair `dot` (,) <$> readPrec <* get <*> readPrec

instance (Show a, Show b) => Show (Pair a b) where
  show (Pair (a, b)) = show a ++ " " ++ show b

infixr 8 `dot`
dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

main :: IO ()
main = do
  (x, n) <- getPair <$> readLn
  if n == 0
    then getLine >> print x
    else do 
      ps <- map read . words <$> getLine
      print $ solve x ps

solve :: Int -> [Int] -> Int
solve x ps
  | x - x1 <= x2 - x = x1
  | otherwise        = x2
 where
  x1 = maximum [ y | y <- [0..x],   y `notElem` ps ]
  x2 = minimum [ y | y <- [x..100], y `notElem` ps ]
