n = int(input())
a = list(map(int, input().split()))
suma = [0 for i in range(n)]
for i in range(n):
    suma[i] = suma[i-1] + a[i]
ans = 0
for i in range(n):
    if suma[i] == 0:
        ans += 1
    for j in range(i):
        if suma[i]-suma[j] == 0:
            ans += 1
print(ans)
