from collections import Counter
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])
ans = 0
A_set = (Counter(A_))
print(sum(v*(v-1)//2 for v in A_set.values()))


