#ABC476C. 第三大的数 / Third Largest Number

第三大的数 / Third Largest Number

Problem Statement

You are given an integer NN not less than 33 and a length-NN sequence of positive integers A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N).

For each k=3,4,…,Nk=3,4,\ldots,N, solve the following problem:

  • When A1,A2,…,AkA_1,A_2,\ldots,A_k are sorted in descending order, find the third value from the front.

Constraints

  • 3≤N≤5×1053\le N\le 5\times 10^5
  • 1≤Ai≤1091\le A_i\le 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN
  • A1A_1 A2A_2 …\ldots ANA_N

Output

Output N−2N-2 lines.

The ii-th line (1≤i≤N−2)(1\le i\le N-2) should contain the answer for k=i+2k=i+2.

5
1 2 1 2 3
1
1
2
  • For k=3k=3: sorting A1,A2,A3A_1,A_2,A_3 in descending order gives 2,1,12,1,1. The third value from the front is 11, so output 11 on the first line.
  • For k=4k=4: sorting A1,A2,A3,A4A_1,A_2,A_3,A_4 in descending order gives 2,2,1,12,2,1,1. The third value from the front is 11, so output 11 on the second line.
  • For k=5k=5: sorting A1,A2,A3,A4,A5A_1,A_2,A_3,A_4,A_5 in descending order gives 3,2,2,1,13,2,2,1,1. The third value from the front is 22, so output 22 on the third line.
10
1 1 1 3 2 5 4 3 6 5
1
1
1
2
3
3
4
5
10
11 9 1 3 17 19 10 19 17 3
1
3
9
11
11
17
17
17