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

s = [a[0]]
for i in range(1, n):
    s.append(s[i-1]+a[i])

cnt = 0
for i in range(n):
    for j in range(i, n):
        buf = s[j] - s[i-1] if (i >= 1) else s[j]
        if buf == 0:
            cnt += 1 
print(cnt) 