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

for i in range(n):
    wa = 0
    for j in range(n-i):
        wa += a[i+j]
        if wa == 0:
            ans += 1
        else:
            pass

print(ans)