{-# LANGUAGE BangPatterns          #-}

import Control.Monad
import Control.Applicative
import Data.Array.IO

maxNum :: Int
maxNum = 100000

main :: IO()
main = do
    n <- readLn :: IO Int
    a <- map read .words <$> getLine :: IO [Int]
    count <- newArray (0, maxNum + 1) 0 :: IO (IOUArray Int Int)
    forM_ a $ \v -> do
        inc count v
        when (v > 0) (inc count (v - 1))
        when (v < maxNum) (inc count (v + 1))
    elems <- getElems count
    print $ maximum elems

    where
        inc arr i = do
            c <- readArray arr i
            writeArray arr i (c + 1)