N = int(eval(input()))

ans = 0

tmp = 0

for _ in range(N):

    a = int(eval(input()))

    if a != 0:

        tmp += a

    else:

        ans += tmp // 2

        tmp = 0

ans += tmp//2



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

tmp = 0

ans = 0

for _ in range(N):

    a = int(eval(input()))

    if a != 0:

        tmp += a

    else:

        ans += tmp // 2

        tmp = 0

ans += tmp // 2

print(ans)

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

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

+tmp = 0 -tmp = 0