n = int(input())
a = list(map(int,input().split()))

b = [0]

for i in range(n):
    b.append(b[i]+a[i])

ans = 0

for i in range(min(b),max(b)+1):
    n = b.count(i)
    
    ans += int((n*(n-1))/2)

print(ans)