from collections import Counter
n=int(input())
A=[0]+list(map(int,input().split()))
for i in range(1,n+1):
    A[i] +=A[i-1]

ans=0
for m in Counter(A).values():
    if m==1:continue
    else:
        ans +=(m*(m-1))//2

print(ans)