splitOnZero :: Integral a => [a] -> [a]
splitOnZero = f []
    where
        f ys [] = reverse $ filter (/=0) ys
        f ys (0 : xs) = f (0 : ys) xs
        f [] (x : xs) = f [x] xs
        f (y : ys) (x : xs) = f (x + y : ys) xs

maxPairs :: Integral a => [a] -> a
maxPairs = sum . fmap (`div` 2) . splitOnZero

main :: IO ()
main = getLine >> getContents >>= print . maxPairs . fmap (read :: String -> Int) . lines
