# -*- coding: utf-8 -*-
"""
Created on Sat Apr 28 21:01:55 2018

@author: Kim
"""

N = int(input())
A = input().split()
A = [ int(x) for x in A]
n = []
ans = 0
for i in range(N):
    n.append(N-i)


for i in range(N):
    for j in range(n[i]):
        j = j + i + 1
        RANGE = A[i:j]
        #print(i, j, RANGE)
        if sum(RANGE) == 0:
            ans += 1

print(ans)
