n = int(eval(input()))

cnt = [0]*n

for i in range(n):

    a = int(eval(input()))

    cnt[i] += a



ans = 0

for i, j in zip(list(range(n-1)), list(range(1, n))):

    x, y = cnt[i], cnt[j]

    z = x//2

    cnt[i] -= 2*z

    ans += z

    if cnt[i] == 0:

        continue

    if 0 < y:

        ans += 1

        cnt[i] -= 1

        cnt[j] -= 1

else:

    ans += cnt[-1]//2



print(ans)
n = int(eval(input()))



ans = x = 0

for _ in range(n):

    a = int(eval(input()))

    if a == 0:

        ans += x//2

        x = 0

    x += a

else:

    ans += x//2



print(ans)
n = int(eval(input()))
cnt = [0] * n
for i in range(n):
    a = int(eval(input()))
    cnt[i] += a
ans = 0
for i, j in zip(list(range(n - 1)), list(range(1, n))):
    x, y = cnt[i], cnt[j]
    z = x // 2
    cnt[i] -= 2 * z
    ans += z
    if cnt[i] == 0:
        continue
    if 0 < y:
        ans += 1
        cnt[i] -= 1
        cnt[j] -= 1
else:
    ans += cnt[-1] // 2
print(ans)

n = int(eval(input()))
ans = x = 0
for _ in range(n):
    a = int(eval(input()))
    if a == 0:
        ans += x // 2
        x = 0
    x += a
else:
    ans += x // 2
print(ans)

-cnt = [0] * n -for i in range(n): +ans = x = 0 +for _ in range(n): -    cnt[i] += a -ans = 0 -for i, j in zip(list(range(n - 1)), list(range(1, n))): -    x, y = cnt[i], cnt[j] -    z = x // 2 -    cnt[i] -= 2 * z -    ans += z -    if cnt[i] == 0: -        continue -    if 0 < y: -        ans += 1 -        cnt[i] -= 1 -        cnt[j] -= 1 +    if a == 0: +        ans += x // 2 +        x = 0 +    x += a -    ans += cnt[-1] // 2 +    ans += x // 2