import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    vs <- V.fromList . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let vmin = V.minimum vs
        vmax = V.maximum vs
    mv <- MV.replicate (vmax - vmin + 3) 0 :: IO (MV.MVector (PrimState IO) Int)
    V.forM_ vs $ \i -> do
        MV.unsafeModify mv succ (i - vmin)
        MV.unsafeModify mv succ (i + 1 - vmin)
        MV.unsafeModify mv succ (i + 2 - vmin)
    v <- V.unsafeFreeze mv
    print $ V.maximum v
