from collections import Counter



N = int(eval(input()))

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



S = [0]



for i, a in enumerate(A):

    S.append(S[i] + a)



S = sorted(S)

a = Counter(S).most_common()

cnt = 0



for i in range(len(a)):

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



print(cnt)

from itertools import accumulate

import collections





N = int(eval(input()))

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



def main():

    # 累積和

    B = [0] + A

    B = list(accumulate(B))



    c = collections.Counter(B)

    cm = c.most_common()



    cnt = 0

    for v in cm:

        if v[1] > 1:

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



    return cnt



print((main()))

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
S = [0]
for i, a in enumerate(A):
    S.append(S[i] + a)
S = sorted(S)
a = Counter(S).most_common()
cnt = 0
for i in range(len(a)):
    cnt += ((a[i][1] - 1) * a[i][1]) // 2
print(cnt)

from itertools import accumulate
import collections

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


def main():
    # 累積和
    B = [0] + A
    B = list(accumulate(B))
    c = collections.Counter(B)
    cm = c.most_common()
    cnt = 0
    for v in cm:
        if v[1] > 1:
            cnt += v[1] * (v[1] - 1) // 2
    return cnt


print((main()))

-from collections import Counter +from itertools import accumulate +import collections -S = [0] -for i, a in enumerate(A): -    S.append(S[i] + a) -S = sorted(S) -a = Counter(S).most_common() -cnt = 0 -for i in range(len(a)): -    cnt += ((a[i][1] - 1) * a[i][1]) // 2 -print(cnt) + + +def main(): +    # 累積和 +    B = [0] + A +    B = list(accumulate(B)) +    c = collections.Counter(B) +    cm = c.most_common() +    cnt = 0 +    for v in cm: +        if v[1] > 1: +            cnt += v[1] * (v[1] - 1) // 2 +    return cnt + + +print((main()))