import Control.Monad
main = do
    n <- read <$> getLine
    as <- map read <$> replicateM n getLine
    putStrLn $ show $ solve as

solve :: [Int] -> Int
solve [] = 0
solve (a:b:cs)
    | a == 0    = solve (b:cs)
    | a > 1     = a `div` 2 + solve (b:cs)
    | b == 1    = 1 + solve cs
    | otherwise = solve (b:cs)
solve (b:[]) = b `div` 2