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


getBysplit = map read . words <$> getLine

main :: IO()
main = do
  [n] <- getBysplit :: IO [Int]
  als <- getBysplit :: IO [Int]
  print $ solve als

countBysame :: (Ord a) => [a] -> [(a, Int)]
countBysame [] = []
countBysame lst = let
                    x:xs = sort lst
                    ((e, c), lst') = sameElem x xs 0
                    in (e, c):countBysame lst'
    where
      sameElem :: (Ord a) => a -> [a] -> Int -> ((a, Int), [a])
      sameElem x [] count = ((x, count+1), [])
      sameElem x (y:ys) count
                    | x ==  y = sameElem x ys (count+1)
                    | x /= y = ((x, count+1), y:ys)

solve :: [Int] -> Int
solve lst = let
            list = concatMap (\x -> [x-1, x, x+1]) lst
            list' = countBysame list
            m = toupleMax list'
            in m
      where
        toupleMax :: [(Int, Int)] -> Int
        toupleMax = foldl (\x (_, y1) -> if x > y1 then x else y1) 0
