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

suma = sum(a)
bubun = suma
ans = 0
if suma == 0:
    ans += 1
for i in range(n-1):
    bubun -= a[n-1-i]
    bubun2 = bubun
    if bubun2 == 0:
        ans += 1
    for j in range(n-1-i):
        if bubun2 == 0:
            ans += 1
        bubun2 -= a[j]
print(ans)
