{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.IntMap as M

readIntLL :: IO [[Int]]
readIntLL = map(unfoldr(B.readInt.B.dropWhile(==' '))).B.lines<$>B.getContents

rsort :: Ord a => [a] -> [a]
rsort = sortBy$flip compare

main=do
    n:as <- readIntLL
    print $ maximum $ map snd $ M.toList
        $ foldl' (\m k -> M.insertWith (+) (k-1) 1 $ M.insertWith (+) (k+1) 1 $ M.insertWith (+) k 1 m) M.empty
        $ head as
