    import qualified Control.Arrow         as Arrow
    import qualified Data.ByteString.Char8 as BSC8
    import qualified Data.Vector.Unboxed   as VU
    import qualified Data.List             as List
    import qualified Data.Ord              as Ord
     
    main :: IO ()
    main = do
      (x, n) <- getAB
      ps     <- getAN n
      print $ if n == 0 then x else solver x ps
     
    solver :: Int -> VU.Vector Int -> Int
    solver x ps = (\(a, b) -> a) . List.minimumBy (Ord.comparing snd) . map (id Arrow.&&& (abs . flip (-) x)) $ [ i | i <- [0..101], VU.notElem i ps]
     
    getI :: BSC8.ByteString -> Maybe (Int, BSC8.ByteString)
    getI = fmap (Arrow.second BSC8.tail) . BSC8.readInt
    getAB :: IO (Int, Int)
    getAB = (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 getI <$> BSC8.getLine
    getAN :: Int -> IO (VU.Vector Int)
    getAN n = VU.unfoldrN n getI <$> BSC8.getLine