n = int(input())
A = list(map(int,input().split()))
S = []
sm = 0
ans=0
for a in A:
    sm += a
    S.append(sm)
S.sort()
for s in S:
    if S[s]==0:
        ans+=1
for s in range(S[n]):
    C=S.count(s)
    for i in range(1,C):
        C=C*i
    pro=C/2
    ans=ans+pro
    pro=0
print(ans)