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

ans = 0
for start in range(N):
    for end in range(start+1, N):
        sum_lst = sum(lst_A[start:end+1])
        if sum_lst == 0:
            ans += 1

print(ans)
