import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM

type Map = IM.IntMap Int

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

solve :: [Int] -> Map -> Map
solve [] m = m
solve (a:as) m = solve as next
  where next = countUp (a + 1) 1 $ countUp (a - 1) 1 $ countUp a 1 m

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  print . maximum . map snd . IM.toList $ solve as IM.empty