n = int(input())
a = list(map(int,input().split()))
s = [0]
sum = 0
for i in range(len(a)):
    sum += a[i]
    s.append(sum)
ans = 0
for s_ in set(s):
    k = s.count(s_)
    ans += k*(k-1)//2
print(ans)
