n = int(input())
A = [int(i) for i in input().split()]
# S = [sum(A[:i]) for i in range(n+1)]
S = [0]*(n+1)
for i in range(n):
    S[i+1] = S[i] + A[i]
out = 0
for i in set(S):
    num = S.count(i)
    out += num*(num-1)//2
print(out)