import Data.List (foldl')

main :: IO ()
main = print . solve . map read . tail . lines =<< getContents

solve :: [Int] -> Int
solve = fst . foldl' (\(a, b) c -> let d = min b c; (e, f) = (c - d) `divMod` 2 in (a + d + e, f)) (0, 0)
