import Data.Array.IO

rInt = read :: String -> Int

main = do
    n <- rInt <$> getLine
    a <- ((map rInt) . words) <$> getLine
    print $ maximum $ map (\x -> length $ filter (\y -> abs (x - y) <= 1) a) [1..99999]
--    print $ maximum $ map snd $ foldr inc3 newCounter a
    