import Data.List
main = mapM_ (print . solve) . analyze . map read . lines =<< getContents
analyze (n:cs) = (n,as):analyze bs where (as,bs) = splitAt n (cs)
analyze [] = []
solve (n,as) = f 0 as
f c (a1:a2:as) = f (c+(a1+a2)`div`2) (min a2 ((a1+a2)`mod`2):as)
f c (a1:as) = c+a1`div`2