module Main where

import Data.List

main :: IO()
main = do
  _ <- getLine
  inputs <- map read . words <$> getLine
  print $ solve inputs

solve :: [Integer] -> Integer
solve inputs = maximum . answers inputs $ posibleXs inputs

posibleXs :: [Integer] -> [Integer]
posibleXs = nub . concatMap (\l -> [l - 1, l, l + 1])

answers :: [Integer] -> [Integer] -> [Integer]
answers inputs = map (\x -> fromIntegral . length $ filter (\n -> x - 1 <= n && n <= x + 1) inputs)
