    import Data.List
    import Data.Ord
    main = do
      t <- readLn :: IO Int
      xs <- fmap (map read . words) getLine :: IO [Int]
      print $ maximum $ map (flip g (f xs)) xs
        where
          f xs = map (\x -> (head x, length x)) $ group $ sort xs
          g n = foldl' (\acc y -> acc + snd y) 0 . filter (\x -> fst x >= n - 1 && fst x <= n + 1)