N=int(eval(input()))

A=[int(i) for i in input().split()]

S=[0]

for num in A:

    S.append(S[-1]+num)

S.sort()



def combination(n):

    if n<2:

        return 0

    else:

        return int(n*(n-1)/2)

    

ans=0

cnt=1

for i in range(N):

    if S[i]==S[i+1]:

        cnt+=1

    else:

        ans+=combination(cnt)

        cnt=1

ans+=combination(cnt)

print(ans)

N=int(eval(input()))

A=[int(i) for i in input().split()]



mp = {0:1}

for i in range(N-1):

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

for a in A:

    if a in mp:

        mp[a]+=1

    else:

        mp[a]=1

res = 0

for v in list(mp.values()):

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

print(res)

N = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0]
for num in A:
    S.append(S[-1] + num)
S.sort()


def combination(n):
    if n < 2:
        return 0
    else:
        return int(n * (n - 1) / 2)


ans = 0
cnt = 1
for i in range(N):
    if S[i] == S[i + 1]:
        cnt += 1
    else:
        ans += combination(cnt)
        cnt = 1
ans += combination(cnt)
print(ans)

N = int(eval(input()))
A = [int(i) for i in input().split()]
mp = {0: 1}
for i in range(N - 1):
    A[i + 1] += A[i]
for a in A:
    if a in mp:
        mp[a] += 1
    else:
        mp[a] = 1
res = 0
for v in list(mp.values()):
    res += v * (v - 1) // 2
print(res)

-S = [0] -for num in A: -    S.append(S[-1] + num) -S.sort() - - -def combination(n): -    if n < 2: -        return 0 +mp = {0: 1} +for i in range(N - 1): +    A[i + 1] += A[i] +for a in A: +    if a in mp: +        mp[a] += 1 -        return int(n * (n - 1) / 2) - - -ans = 0 -cnt = 1 -for i in range(N): -    if S[i] == S[i + 1]: -        cnt += 1 -    else: -        ans += combination(cnt) -        cnt = 1 -ans += combination(cnt) -print(ans) +        mp[a] = 1 +res = 0 +for v in list(mp.values()): +    res += v * (v - 1) // 2 +print(res)