from collections import *
from itertools import *
n = int(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
c = Counter(b)
r = 0
for i in range(n):
    c[b[i]] -= 1
    r += c[b[i]-a[i]]
print(r)