from collections import Counter

n = int(eval(input()))

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

S = [0]*(n+1)

for i in range(n):

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

def hello(data):

    dt = Counter()

    for i in data:

        dt[str(i)] += 1

    return dt

num = hello(S)

out = [i*(i-1)//2 for i in list(num.values()) if i>1]

print((sum(out)))
n = int(eval(input()))

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

S = [0]*(n+1)

num={}

for i in range(n):

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

for i in S:

    if str(i) in list(num.keys()):

        num[str(i)] += 1

    else:

        num[str(i)] = 1

out = [i*(i-1)//2 for i in list(num.values()) if i>1]

print((sum(out)))
from collections import Counter

n = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0] * (n + 1)
for i in range(n):
    S[i + 1] = S[i] + A[i]


def hello(data):
    dt = Counter()
    for i in data:
        dt[str(i)] += 1
    return dt


num = hello(S)
out = [i * (i - 1) // 2 for i in list(num.values()) if i > 1]
print((sum(out)))

n = int(eval(input()))
A = [int(i) for i in input().split()]
S = [0] * (n + 1)
num = {}
for i in range(n):
    S[i + 1] = S[i] + A[i]
for i in S:
    if str(i) in list(num.keys()):
        num[str(i)] += 1
    else:
        num[str(i)] = 1
out = [i * (i - 1) // 2 for i in list(num.values()) if i > 1]
print((sum(out)))

-from collections import Counter - +num = {} - - -def hello(data): -    dt = Counter() -    for i in data: -        dt[str(i)] += 1 -    return dt - - -num = hello(S) +for i in S: +    if str(i) in list(num.keys()): +        num[str(i)] += 1 +    else: +        num[str(i)] = 1