from itertools import accumulate

N = int(input())
count = [0 for i in range(N+1)]
count[0] += 1
for i in accumulate([int(x) for x in input().split()]):
    count[i] += 1
ans = 0
for i in count:
    ans += (i*(i-1)) // 2
print(ans)
