n = int(input())
a = list(map(int,input().split()))
sum = 0
s = 0
l = [0]
p = {0}
for i in range(n):
    sum = sum + a[i]
    p = p | {sum}
    l.append(sum)

for thing in p:
    de = l.count(thing)
    s += (de * (de-1)) / 2

print(int(s))