import math

n = int(input())
a = list(map(int, input().split()))
s = [0]
b = 0

for i in range(n):
    s.append(s[i] + a[i])
s.sort()

for i in set(s):
    b += math.factorial(s.count(i)-1)
print(b)
