import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  solve <$> replicateM n (getl toInt) >>= print

solve :: [Int] -> Int
solve xs = f 0 xs
  where
    f a [x] = a + x `div` 2
    f a (x:y:ys)
      | x == 0 = f a (y:ys)
      | y == 0 = f (a + x `div` 2) ys
      | even x = f (a + x `div` 2) (y:ys)
      | otherwise = f (a + 1 + x `div` 2) ((y-1):ys)

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine
