import           Data.List
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

hoge :: [Int] -> State ([Int], Int) ()
hoge []       = return ()
hoge (a : as) = do
  (rs, b) <- get
  let nrs = a : takeWhile (>= (a - 2)) rs
  put (nrs, maximum [b, length nrs])
  hoge as

main = do
  n  <- readLn
  ns <- sort . take n . map (read :: String -> Int) . words <$> getLine
  print $ snd $ execState (hoge ns) ([], 0)
