import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as IM
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:as)=IM.fold max 0.foldr(\a m->foldr f m[a-1,a,a+1])IM.empty$as
f a m
  |IM.member a m=IM.adjust succ a m
  |otherwise=IM.insert a 1 m