import Data.List

main = do
    let toInt = (read :: String -> Int) 
    xs <- getLine >>= return . map toInt . words
    let lx = xs !! 0
    let ln = xs !! 1
    if ln == 0
        then
          print lx
        else 
          do
            pn <- getLine >>= return . take ln . map toInt . words
            let an = map fst $ sortBy (\x y -> compare (snd x) (snd y)) $ map (\x -> ((lx - x), abs (lx - x))) pn
            let minAbsDiff = head $ filter (\x -> notElem x an || notElem (-1 * x) an) [0..]
            let neg = elem (lx - minAbsDiff) pn
            print $ if neg then (lx + minAbsDiff) else (lx - minAbsDiff)

