N = int(input())
a = list(map(int, input().split()))
s = [0] * (N + 1)

for i in range(N):
    s[i + 1] = s[i] + a[i]
    
ans = 0
cnt = 0
S = list(set(s))
for i in S:
    n = s.count(i)
    
    if n >= 2:
        ans += n * (n - 1) // 2
        
print(ans)