import Control.Applicative
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [x, n] <- f
  if n == 0 then print x
    else solve x <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> Int
solve x ps = f 0
  where
    st = IS.fromList ps
    f i
      | IS.notMember (x - i) st = x - i
      | IS.notMember (x + i) st = x + i
      | otherwise = f (i + 1)
