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

res = 0

for i in range(1,n+1):
    lon = i
    #print(lon)
    for j in range(n-lon+1):
        if sum(a[j:j+lon]) == 0:
            #print(a[j:j+lon])
            res += 1
else:
    print(res)
