scan :: [Int] -> Int
scan = iter 0 [] 0 where
    iter c _ _ [] = c + 1
    iter c ps pl (x:xs)
        | pl <  x = iter c (take (x -pl) (repeat 0) ++ ps) x xs
        | otherwise = case post ss of
            Just ns -> iter c ns x xs
            Nothing -> iter (c+1) (incr ss) x xs
        where
            ss = drop (pl -x) ps
            incr (x:xs) = (x+1):xs
            post [] = Nothing
            post (x:xs)
                | c > x     = Just ((x+1):xs)
                | otherwise = fmap (0:) (post xs)

readData :: IO [Int]
readData = do
    line1 <- getLine
    let xs = map (\x -> read x :: Int) (words line1)
    return xs

main :: IO() 
main = do
    n  <- readLn :: IO Int
    la <- readData
    let ans = scan la
    print ans