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

C = [0 for _ in A]
C[0] = A[0]
for i in range(1, len(A)):
    C[i] = C[i-1] + A[i]

from collections import Counter
from scipy.special import comb
count = Counter(C)

li = list(count.values())

res = 0
for l in li:
    if l == 1:
        pass
    else:
        res += comb(l, 2)
res += count[0]

print(int(res))