from itertools import accumulate
n = int(input())
a = [int(i) for i in input().split()]
b = list(accumulate(a))
ans = 0
c = list(set(b))
for cc in c:
    num = b.count(cc)
    ans += (num * (num - 1)) // 2
ans += b.count(0)
print(ans)