def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    
#    print(A)
    result = 0
    for nc_len in range(1, N + 1):
        for i in range(N - nc_len + 1):
#            print(A[i : i + nc_len])
            if(sum(A[i : i + nc_len]) == 0):
                result += 1
    
    print(result)
    
if __name__=="__main__":
    main()