import Data.Array.IO

rInt = read :: String -> Int

type Counter = [(Int, Int)]

newCounter :: Counter
newCounter = []

increment :: Counter -> Int -> Counter
increment [] k = [(k, 1)]
increment ((k, v):r) k' = if k==k' then ((k, v+1):r) else ((k, v):increment r k')

inc3 x c = foldr (\k ct -> increment ct k) c [x-1..x+1]

main = do
    n <- rInt <$> getLine
    a <- ((map rInt) . words) <$> getLine
    print $ maximum $ map snd $ foldr inc3 newCounter a
    