
module Main where

import Debug.Trace

main :: IO ()
main = do
  [a, _] <- map read . words <$> getLine
  s <- map read . words <$> getLine
  --a `traceShow`
  --(take 10 $ iterate (+1) 0) `traceShow`
  print $ solve a s

solve :: Int -> [Int] -> Int
solve a s = check a s (take 110 $ iterate (+1) 0)


check :: Int -> [Int] -> [Int] -> Int
check a s (p:ps)
  | a - p >= 1   && not (a - p `elem` s) = a - p
  | a + p <= 100 && not (a + p `elem` s) = a + p
  | otherwise = check a s ps
