import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  let
    ds = 0 : concatMap (\d -> [-d, d]) [1..] :: [Int]
  [x, n] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ps <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    ps' = IS.fromList ps :: IntSet
  print . head . filter (`IS.notMember` ps') . map (x +) $ ds

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
