N = int(input())
a = list(map(int, input().split()))
for i in range(N-1):
    a[i+1] += a[i]
a.sort()
ans = 0
be = 1<<31
cnt = 0
for x in a:
    if x != be:
        if be == 0:
            cnt += 1
        ans += cnt*(cnt-1)//2
        be = x
        cnt = 0
    cnt += 1
ans += cnt*(cnt-1)//2
print(ans)
