#abc234d. [abc234_d]Prefix K-th Max

[abc234_d]Prefix K-th Max

Problem Statement

Given are a permutation P=(P1,P2,ldots,PN)P=(P_1,P_2,\\ldots,P_N) of (1,2,ldots,N)(1,2,\\ldots,N) and a positive integer KK.

For each i=K,K+1,ldots,Ni=K,K+1,\\ldots,N, find the following.

  • The KK-th greatest value among the first ii terms of PP.

Constraints

  • 1leqKleqNleq5times1051 \\leq K \\leq N \\leq 5 \\times 10^5
  • (P1,P2,ldots,PN)(P_1,P_2,\\ldots,P_N) is a permutation of (1,2,ldots,N)(1,2,\\ldots,N).
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK P1P_1 P2P_2 ldots\\ldots PNP_N

Output

For each i=K,K+1,ldots,Ni=K, K+1, \\ldots, N, in this order, print the specified value in Problem Statement, separated by newlines.


Sample Input 1

3 2
1 2 3

Sample Output 1

1
2
  • The (K=)(K=) 22-nd greatest value among the first 22 terms of PP, (P1,P2)=(1,2)(P_1,P_2)=(1,2), is 11.
  • The (K=)(K=) 22-nd greatest value among the first 33 terms of PP, (P1,P2,P3)=(1,2,3)(P_1,P_2,P_3)=(1,2,3), is 22.

Sample Input 2

11 5
3 7 2 5 11 6 1 9 8 10 4

Sample Output 2

2
3
3
5
6
7
7