import collections
n = int(input())
a = [int(i) for i in input().split()]
acc = [0]
for i in range(n):
    acc.append(acc[-1] + a[i])
dic = collections.defaultdict(int)
for i in range(n+1):
    dic[acc[i]] += 1
ans = 0
ls1 = [1]
for i in range(1,n+1):
    ls1.append(ls1[-1] * i)

for key in dic.keys():
    ans += ((dic[key] * (dic[key]-1)) /2)
print(int(ans))
