N = int(input())
a = list(map(int,input().split()))
n = 0
for i in range(1,N+1):
    for j in range(N+1-i):
        b = a[j:j+i]
        S = 0
        for x in b:
            S += x
        if S == 0:
            n += 1
print(n)