n = int(eval(input()))

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



acc = [0 for i in range(n+1)]

for i in range(n):

    acc[i+1] = a[i] + acc[i]



ans = {}

for x in acc:

    ans.setdefault(x, 0)

    ans[x] += 1

cnt = 0

for i in ans:

    cnt += ans[i]*(ans[i]-1)//2



print(cnt)
from itertools import accumulate

from collections import Counter



n = int(eval(input()))

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



acc =  accumulate(a)

counter = Counter(acc)

def cal():

    yield counter[0]

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

        if v > 1:

            yield v*(v-1)//2



print((sum(cal())))
n = int(eval(input()))
a = list(map(int, input().split()))
acc = [0 for i in range(n + 1)]
for i in range(n):
    acc[i + 1] = a[i] + acc[i]
ans = {}
for x in acc:
    ans.setdefault(x, 0)
    ans[x] += 1
cnt = 0
for i in ans:
    cnt += ans[i] * (ans[i] - 1) // 2
print(cnt)

from itertools import accumulate
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
acc = accumulate(a)
counter = Counter(acc)


def cal():
    yield counter[0]
    for v in list(counter.values()):
        if v > 1:
            yield v * (v - 1) // 2


print((sum(cal())))

+from itertools import accumulate +from collections import Counter + -acc = [0 for i in range(n + 1)] -for i in range(n): -    acc[i + 1] = a[i] + acc[i] -ans = {} -for x in acc: -    ans.setdefault(x, 0) -    ans[x] += 1 -cnt = 0 -for i in ans: -    cnt += ans[i] * (ans[i] - 1) // 2 -print(cnt) +acc = accumulate(a) +counter = Counter(acc) + + +def cal(): +    yield counter[0] +    for v in list(counter.values()): +        if v > 1: +            yield v * (v - 1) // 2 + + +print((sum(cal())))