import collections

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]

ans = 0
c = list(collections.Counter(s).values())
for i in c:
  ans += i*(i-1)//2
print(ans)
