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

s = [0]*(n+1)

cnt = 0

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

print(cnt)