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

s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]

cnt = 0
import itertools
for l,r in itertools.product(range(1,n+1),range(1,n+1)):
    if l >= r:
        if l == r:
            if a[l-1] == 0:
                cnt += 1
        continue
    if s[r] - s[l-1] == 0:
        cnt += 1

print(cnt)