# sys.stdin.readline()
import sys
input = sys.stdin.readline

from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += list(accumulate(a[i:])).count(0)
print(ans)