from collections import Counter
N = int(input())
a = list(map(int, input().split()))
count = 0
s = list()
s.append(0)
for i in range(N):
  s.append(a[i] + s[i])
for j in  Counter(s).values():
  count += (j * (j-1))/2
print(int(count))