from itertools import accumulate
from collections import Counter

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

b = list(accumulate(a))
b = [0]+b

c = Counter(b)
ans = 0
for x in c:
    ans += c[x]*(c[x]-1)//2

print(ans)