import Control.Monad
import Control.Applicative

main :: IO ()
main = getLine >>= \_ -> fmap ((map read) . lines) getContents >>= \an -> print $ solve 1 an


-- subtractor -> 
solve :: Int -> [Int] -> Int
solve _   [] = 0
solve sub (a:an)
  | sub < a   = if a-sub == sub && sub /= 1 then 1 + solve sub ((a-sub-1):an) else 1 + solve sub ((a-sub):an)
  | sub > a   = solve sub an
  | otherwise = solve (sub+1) an