# -*- coding: utf-8 -*-

n = int(input())
A = [int(s) for s in input().split()]

count = 0

for i in range(0, len(A)-1):
    mul = A[i]
    for j in range(i+1, len(A)):
        mul += A[j]
        if mul == 0:
            count += 1
    
            
print(count)
