import qualified Data.IntSet as S

main = do
    li <- getLine
    let [x,n] = map read $ words li
    li <- getLine
    let ps = map read $ words li
    let ans = compute x n ps
    print ans

compute :: Int -> Int -> [Int] -> Int
compute x n ps = head $ filter (flip S.notMember pS) cands
  where
    pS = S.fromList ps
    cands = x : [ y | i <- [1..], y <- [x-i,x+i] ]
