n = int(input())
a = list(map(int,input().split()))
ls = [a[0]]
for i in range(1,n):
    ls.append(a[i]+ls[i-1])
    
ans = 0
k = 1
for i in range(n):
    if ls[i] == 0:
      ans += 1
    for j in range(k,n):
        if ls[i] == ls[j]:
            ans += 1
    k += 1

print(ans)