n = int(input())
a = list(map(int, input().split()))
sum = 0
sum_list = []
for i in range(n):
    sum += a[i]
    sum_list.append(sum)
    
ans = 0
for i in range(n):
    same = sum_list.count(sum_list[i])
    if same > 1:
        num = 0
        for j in range(same-1):
            num += j+1
        ans += num/same
    if sum_list[i] == 0:
        ans += 1        

print(int(ans))