N = int(input())
A = list(map(int,input().split()))

C = []
for i in range(N):
    C.append(sum(A[i:]))
    
ans = len(list(filter(lambda x:x==0,C)))

for j in range(0,N)[::-1]:
    C = list(map(lambda x:x-A[j],C))[:j]
    ans += len(list(filter(lambda x:x==0,C)))
    
print(ans)