n = int(input())
a = list(map(int, input().split(" ")))
s = []
s.append(a)
counter = 0
for i in range(1, n):
    s.append([])
    for j in range(n - i):
        # print(s[i])
        s[i].append(s[i-1][j] + a[j+i])
        if s[i-1][j] + a[j+i] == 0:
            counter += 1

print(counter)