n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]
for i in range(n):
    lst2.append(sum(lst[:i+1]))

temp = set()

for i in range(n):
    l = lst2.count(i)
    if l > 1 and i not in temp:
        temp.add(i)
        ans += l*(l-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""