import Data.List

count :: Int -> [(Int, Int)] -> Int
count n = sum . map snd . filter (\(x, _) -> x == (n-1) || x == n || x == (n+1))

solve :: [Int] -> Int
solve xs =
    let ys = map (\xs -> (head xs, length xs)) . group . sort $ xs
        zs = map head . group . sort . concatMap (\x -> [x - 1, x, x + 1]) $ xs
    in maximum . map (flip count ys) $ zs

main = getLine >> map read . words <$> getLine >>= print . solve
