N = int(input())
a = [int(a_i) for a_i in input().split()]
s = [0]  # s[i] = a[1]からa[i]までの総和
sum = 0
for i in range(N):
    sum += a[i]
    s.append(sum)
ans = 0
for i in range(N):
    for j in range(i, N):
        if s[j] - s[i-1] == 0:
            ans += 1
print(ans)
