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