import Data.List
import qualified Data.Map as M

main :: IO ()
main = do
 [x,_] <- map read . words <$> getLine :: IO [Int]
 pList <- map read . words <$> getLine) :: IO [Int]
 print $ solve M.getList(pList) [x,x]

solve pList [small,big]
 | !(pList (M.!) small) && !(pList (M.!) big) = solve pList [small - 1, big + 1]
 | otherwies = small