import Control.Monad

main = do
  [x,n] <- map read . words <$> getLine :: IO [Int]
  ps <- map read . words <$> getLine :: IO [Int]
  print $ head (run x x ps)
  return ()

 where
  run :: Int -> Int -> [Int] -> [Int]
  run number1 number2 ps =
    if number1 `elem` ps && number2 `elem` ps
       then run (number1-1) (number2+1) ps 
       else if not (number1 `elem` ps || number2 `elem` ps)
        then [number1, number2]
        else if not (number1 `elem` ps) && number2 `elem` ps
        then [number1]
        else if number1 `elem` ps && not (number2 `elem` ps)
        then [number2]
        else error "no"