import Data.List

main = do
  _ <- getLine
  ns <- map read <$> words <$> getLine
  print $ solve ns

solve :: [Int] -> Int
solve = maximum . map length . group . sort . concatMap (\n -> [n-1, n, n+1])