n = int(input())
a = list(map(int, input().split()))
if n == 1:
    if a[0] == 0:
        ans = 1
    else:
        ans = 0      
else:
    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))