from collections import Counter
n = int(input())
A = list(map(int,input().split()))

acum = [0]*(n+1)
for i in range(n):
  acum[i+1] = acum[i] + A[i]
  
ans = 0
for k,v in Counter(acum).items():
  ans += v*(v-1)//2
  
print(ans)  