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

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

ans = 0
for j in range(n):
    for k in range(j+1, n+1):
        if ary_2[j] == ary_2[k]:
            ans += 1

print(ans)