N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    SUM = 0
    for j in range(i, N):
        SUM += A[j]
        # print(SUM, A[i:j + 1])
        if SUM == 0:
            ans += 1
print(ans)
