import Data.List
main = do
  [x, n] <- map read . words <$> getLine
  if n == 0
    then print x
    else do
      ns <- map read . words <$> getLine
      print $ solve ns x

solve ns x = head $ dropWhile (flip elem ns) xs
  where
    xs = (x:) . concat $ zipWith (\a b -> [a, b]) [x-1, x-2..] [x+1, x+2..]