N,*A=list(map(int,open(0)));p=f=0

for a,b in zip(A,A[1:]):d,m=divmod(a-f,2);f=min(m,b);p+=d+f

print((p+(A[-1]-f)//2))
N,*A=list(map(int,open(0)));p=f=0

for a in A:d,m=divmod(a+f,2);p+=d;f=m&(a>0)

print(p)
N, *A = list(map(int, open(0)))
p = f = 0
for a, b in zip(A, A[1:]):
    d, m = divmod(a - f, 2)
    f = min(m, b)
    p += d + f
print((p + (A[-1] - f) // 2))

N, *A = list(map(int, open(0)))
p = f = 0
for a in A:
    d, m = divmod(a + f, 2)
    p += d
    f = m & (a > 0)
print(p)

-for a, b in zip(A, A[1:]): -    d, m = divmod(a - f, 2) -    f = min(m, b) -    p += d + f -print((p + (A[-1] - f) // 2)) +for a in A: +    d, m = divmod(a + f, 2) +    p += d +    f = m & (a > 0) +print(p)