{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Map as MP
import Data.Char
import Data.List
import Control.Monad
import Debug.Trace

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    (ys :: VUM.IOVector Int) <- VUM.replicate  (10^5+1) 0
    VU.mapM_ (\x -> VUM.modify ys (+1) x) xs
    res <- VU.forM (VU.fromList [0..10^5]) $ \i -> do
        as <- forM [(max (i-1) 0)..(min (i+1) (10^5))] $ VUM.read ys 
        return $ Data.List.sum as
    print $ VU.maximum res