main = do
    [x,n] <- map read . words <$> getLine :: IO [Int]
    ps <- map read . words <$> getLine :: IO [Int]
    print $ if n == 0
                then x
                else head $ [x + s * d | d <- [0..x], s <- [-1,1], notElem (x + s * d) ps ]
