import Data.List
main = do
  [x,n] <- map (read :: String -> Int) . words <$> getLine
  p <- map (read :: String -> Int) . words <$> getLine
  print $ solve x n p


solve x n p =
  if n == 0
  then x
  else do
    let xs = [1..maximum p]
    let d = [x | x <- xs, notElem x p]
    foldl (\a b -> if abs (a - x) < abs (b - x) then a else b) 1 d
