N=int(input())
A=list(map(int,input().split()))
sum=[0]*(N+1)
for i in range(N):
        sum[i+1]=sum[i]+A[i]
sum.sort()
k=0
ans=0
for i in range(N):
        if sum[i]==sum[i+1]:k+=1
        else:k=0
        ans+=k
print(ans)