n = int(input())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
    x = 0
    x += b[i] + a[i]
    b.append(x)
b.sort()
check = 1000000000000
ans = 0
for i in range(n+1):
    if b[i] != check:
        y = b.count(b[i])
        ans += y * (y - 1) //2
        check = b[i]
print(ans)
    

