# AGC023
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
ans = 0
for i in range(N):
    tmp = A[i:N]
    rest = np.cumsum(tmp)
    ans += np.count_nonzero(rest == 0)
print(ans)