n = int(input())
a = [int(i) for i in input().split()]
# print(n, a)

import itertools
l = [i for i in range(n+1)]
c = list(itertools.combinations(l,2))
# print(c)

cnt = 0
for i in c:
    if sum(a[i[0]:i[1]]) == 0:
        # print(i)
        # print(a[i[0]:i[1]])
        cnt += 1
print(cnt)