import Data.List
import Data.Ord
main = do
  t <- readLn :: IO Int
  xs <- fmap (map read . words) getLine :: IO [Int]
  print $ maximum . map length . group . sort . foldl (\acc x -> (x - 1) : x : (x + 1) : acc) [] xs