from collections import Counter
n = int(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]
out = [i*(i-1)//2 for i in Counter(S).values() if i > 1]
print(sum(out))