n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i+1] = sa[i] + a[i]

nums = list(set(sa))
for num in nums:
    num_cnt[num] = sa.count(num)
res = 0
for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)