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

    ans = 0

    for seqlen in range(1, N + 1):
        for idx in range(N - seqlen + 1):
            if sum(A[idx:idx + seqlen]) == 0:
                ans += 1

    print(ans)

main()
