from collections import Counter



n = int(eval(input()))

A = list(map(int, input().split()))

cum_sum = [0] * (n+1)

for i in range(n):

    cum_sum[i+1] = cum_sum[i] + A[i]

C = Counter(cum_sum[1:])

ans = 0

for k, v in list(C.items()):

    if k == 0:

        ans += v + (v*(v-1)//2)

    else:

        ans += (v*(v-1)//2)

print(ans)

from collections import Counter



n = int(eval(input()))

A = list(map(int, input().split()))

cum_sum = [0] * (n+1)

for i in range(n):

    cum_sum[i+1] = cum_sum[i] + A[i]

C = Counter(cum_sum[1:])

ans = C[0]

for k, v in list(C.items()):

    ans += (v*(v-1)//2)

print(ans)

from collections import Counter

n = int(eval(input()))
A = list(map(int, input().split()))
cum_sum = [0] * (n + 1)
for i in range(n):
    cum_sum[i + 1] = cum_sum[i] + A[i]
C = Counter(cum_sum[1:])
ans = 0
for k, v in list(C.items()):
    if k == 0:
        ans += v + (v * (v - 1) // 2)
    else:
        ans += v * (v - 1) // 2
print(ans)

from collections import Counter

n = int(eval(input()))
A = list(map(int, input().split()))
cum_sum = [0] * (n + 1)
for i in range(n):
    cum_sum[i + 1] = cum_sum[i] + A[i]
C = Counter(cum_sum[1:])
ans = C[0]
for k, v in list(C.items()):
    ans += v * (v - 1) // 2
print(ans)

-ans = 0 +ans = C[0] -    if k == 0: -        ans += v + (v * (v - 1) // 2) -    else: -        ans += v * (v - 1) // 2 +    ans += v * (v - 1) // 2