n = int(input())
a = list(map(int, input().split()))
b = [0]
for i, num in enumerate(a):
    b.append(b[i] + a[i])
count = []
for num in list(set(b)):
    count.append(b.count(num))
ans = int(sum([(i*(i-1))/2 for i in count]))
print(ans)