atcoder#ARC095A. [ABC094C] Many Medians

[ABC094C] Many Medians

Score : 300300 points

Problem Statement

When ll is an odd number, the median of ll numbers a1,a2,...,ala_1, a_2, ..., a_l is the (l+12)(\frac{l+1}{2})-th largest value among a1,a2,...,ala_1, a_2, ..., a_l.

You are given NN numbers X1,X2,...,XNX_1, X_2, ..., X_N, where NN is an even number. For each i=1,2,...,Ni = 1, 2, ..., N, let the median of X1,X2,...,XNX_1, X_2, ..., X_N excluding XiX_i, that is, the median of X1,X2,...,Xi1,Xi+1,...,XNX_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be BiB_i.

Find BiB_i for each i=1,2,...,Ni = 1, 2, ..., N.

Constraints

  • 2N2000002 \leq N \leq 200000
  • NN is even.
  • 1Xi1091 \leq X_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

X1X_1 X2X_2 ... XNX_N

Output

Print NN lines. The ii-th line should contain BiB_i.

4
2 4 4 3
4
3
3
4
  • Since the median of X2,X3,X4X_2, X_3, X_4 is 44, B1=4B_1 = 4.
  • Since the median of X1,X3,X4X_1, X_3, X_4 is 33, B2=3B_2 = 3.
  • Since the median of X1,X2,X4X_1, X_2, X_4 is 33, B3=3B_3 = 3.
  • Since the median of X1,X2,X3X_1, X_2, X_3 is 44, B4=4B_4 = 4.
2
1 2
2
1
6
5 5 4 4 3 3
4
4
4
4
4
4