n = int(input())
a = list(map(int, input().split()))
s = [0]
s.extend([sum(a[0:i+1]) for i in range(n)])
s.sort()

result = 0
count = 1
for i in range(n):
    if s[i] == s[i+1]:
        count += 1
    else:
        result += count * (count - 1) // 2
        count = 1
result += count * (count - 1) // 2

print(result)