import Data.List
import Data.Bool

main = print . solve . map (\xs -> (head xs, length xs)) . group . sort . map read . drop 1 . words =<< getContents

solve :: [(Int,Int)] -> Int
solve xls = maximum $ zipWith3 (\(a,al) (b,bl) (c,cl) -> bl + (bool 0 al $ abs(a-b) == 1) + (bool 0 cl $ abs(c-b) == 1)) xls' (drop 1 xls') (drop 2 xls')
    where
        xls' = [(0,0)] ++ xls ++ [(0,0)]
