n = int(input())
a = list(map(int,input().split()))
s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
import collections
c = collections.Counter(s)
ans = 0
d = list(set(s))
for D in d:
    ans += c[D]*(c[D]-1)//2
print(ans)