N = int(input())
A = list(map(int,input().split()))
c = 0
A_ = [0]
for i in range(0,N):
  A_.append(A_[i]+A[i])
A_.sort()
A_set = list(set(A_))
ans = 0
for i in A_set:
  n = A_.count(i)
  ans += n*(n-1)//2
print(ans)

