Yuuka has a binary tree with vertices which are conveniently labeled with 1,2,…,n. For each i≥2, there is an edge between vertices i and ⌊i/2⌋. The i-th vertex has weight w_i associated with it, and all weights are distinct.
Consider a subtree of the given tree (a subgraph which is itself a tree) which consists of vertices v_1,v_2,…,v_k such that w_v_1<w_v_2<⋯<w_v_k. The a-median of this subtree is then w_v_⌊(k−a+1)/2⌋ for 0≤a<k.
For each a∈0,1,2,…,n−1, find the largest a-median among all subtrees of the given tree.
The input contains zero or more test cases, and is terminated by end-of-file. For each test case:
The first line contains an integer n (1≤n≤2⋅105).
The second line contains n integers w_1,w_2,…,w_n (1≤w_i≤n, and the numbers w_1,w_2,…,w_n are all distinct). It is guaranteed that the sum of all n does not exceed 2⋅105.
For each test case, output n integers M_0,M_1,…,M_n−1 where M_a denotes the largest a-median.