def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    for i in range(1, N+1):
        for j in range(N-i+1):
            if sum(A[j:j+i]) == 0:
                count += 1
    return count

if __name__ == '__main__':
    print(main())

