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

ans = 0
suma0 = [0 for i in range(n)]

if a[0] == 0:
    ans+=1
else:
    suma0[0] = a[0]

for i in range(1, n):
    suma0[i] = suma0[i-1] + a[i]
    if suma0[i] == 0:
        ans += 1

for i in range(1,n):
    for j in range(i, n):
        suma0[j] -= a[i-1]
        if suma0[j] == 0:
            ans += 1

print(ans)