import Data.List
import Data.Ord
main = do
  t <- readLn :: IO Int
  xs <- fmap (map read . words) getLine :: IO [Int]
  print $ maximum $ map (flip f xs) [minimum xs - 1 .. maximum xs + 1]
    where f n = length . filter (\x -> let d = x - n in d >= -1 && d <= 1)