N = int(eval(input()))

A = []

a = []

for i in range(N):

    x = int(eval(input()))

    if x==0:

        b = a[:]

        A.append(b)

        a = []

    else:

        a.append(x)

A.append(a)

cnt = 0

for a in A:

    c = sum(a)

    cnt += c//2

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

A = [int(eval(input())) for _ in range(N)]

cnt = 0

for i in range(N):

    if A[i]%2==1:

        cnt += A[i]//2

        A[i] = 1

    else:

        a = A[i]//2

        if a>0:

            cnt += a-1

            A[i] = 2

for i in range(1,N):

    if A[i-1]!=1:

        cnt += A[i-1]//2+A[i]//2

        A[i-1]=0

        A[i]=A[i]%2

    elif A[i-1]==1 and A[i]>=1:

        cnt += 1

        A[i-1]=0

        A[i] -= 1

if N==1:

    cnt = A[0]//2

print(cnt)
N = int(eval(input()))
A = []
a = []
for i in range(N):
    x = int(eval(input()))
    if x == 0:
        b = a[:]
        A.append(b)
        a = []
    else:
        a.append(x)
A.append(a)
cnt = 0
for a in A:
    c = sum(a)
    cnt += c // 2
print(cnt)

N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
cnt = 0
for i in range(N):
    if A[i] % 2 == 1:
        cnt += A[i] // 2
        A[i] = 1
    else:
        a = A[i] // 2
        if a > 0:
            cnt += a - 1
            A[i] = 2
for i in range(1, N):
    if A[i - 1] != 1:
        cnt += A[i - 1] // 2 + A[i] // 2
        A[i - 1] = 0
        A[i] = A[i] % 2
    elif A[i - 1] == 1 and A[i] >= 1:
        cnt += 1
        A[i - 1] = 0
        A[i] -= 1
if N == 1:
    cnt = A[0] // 2
print(cnt)

-A = [] -a = [] +A = [int(eval(input())) for _ in range(N)] +cnt = 0 -    x = int(eval(input())) -    if x == 0: -        b = a[:] -        A.append(b) -        a = [] +    if A[i] % 2 == 1: +        cnt += A[i] // 2 +        A[i] = 1 -        a.append(x) -A.append(a) -cnt = 0 -for a in A: -    c = sum(a) -    cnt += c // 2 +        a = A[i] // 2 +        if a > 0: +            cnt += a - 1 +            A[i] = 2 +for i in range(1, N): +    if A[i - 1] != 1: +        cnt += A[i - 1] // 2 + A[i] // 2 +        A[i - 1] = 0 +        A[i] = A[i] % 2 +    elif A[i - 1] == 1 and A[i] >= 1: +        cnt += 1 +        A[i - 1] = 0 +        A[i] -= 1 +if N == 1: +    cnt = A[0] // 2