module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Data.Ord (comparing)

main :: IO ()
main = do
    getLine
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = [a + i | a <- as,  i <- [-1, 0, 1]]
    let ans = length . maximumBy (comparing length) . group . sort $ bs
    print ans