{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

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

main=do
    n <- readLn::IO Int
    print =<<  head . sortBy (flip compare) . map snd . M.toList
            . foldl' (\m k -> M.insertWith (+) (k-1) 1 $ M.insertWith (+) (k+1) 1 $ M.insertWith (+) k 1 m) M.empty
            . unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine
