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

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

count = 0

for i in range(N):
    sum = a[i]
    for j in range(1, N-i):
        sum += a[i+j]
        if sum == 0:
            count += 1
print(count)