Problem:
Score : 300 points

Problem Statement

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

You are given N numbers X_1, X_2, ..., X_N, where N is an even number.
For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.

Find B_i for each i = 1, 2, ..., N.

Constraints

2 \leq N \leq 200000

N is even.

1 \leq X_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
X_1 X_2 ... X_N

Output

Print N lines.
The i-th line should contain B_i.

Sample Input 1

4
2 4 4 3

Sample Output 1

4
3
3
4

Since the median of X_2, X_3, X_4 is 4, B_1 = 4.

Since the median of X_1, X_3, X_4 is 3, B_2 = 3.

Since the median of X_1, X_2, X_4 is 3, B_3 = 3.

Since the median of X_1, X_2, X_3 is 4, B_4 = 4.

Sample Input 2

2
1 2

Sample Output 2

2
1

Sample Input 3

6
5 5 4 4 3 3

Sample Output 3

4
4
4
4
4
4

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        char[][] map = Enumerable.Repeat(0, hw[0]).Select(_ => Console.ReadLine().ToArray()).ToArray();
        //並び替えた後でも、同じ列だったものは同じ列、同じ行だったものも同じ行。
        //自分と対応する列があると嬉しいかも…?
        int[][] countChari = Enumerable.Repeat(0, hw[0]).Select(_ => new int[26]).ToArray();
        int[][] countCharj = Enumerable.Repeat(0, hw[1]).Select(_ => new int[26]).ToArray();
        for (int i = 0; i < hw[0]; i++)
        {
            for (int j = 0; j < hw[1]; j++)
            {
                countChari[i][map[i][j] - 'a']++;
                countCharj[j][map[i][j] - 'a']++;
            }
        }
        
        //偶数だったらあぶれ者を真ん中とかに持ってこれるから嬉しい
        bool canConstructi = canConstruct(countChari);
        bool canConstructj = canConstruct(countCharj);
        Debug.WriteLine(Hash(map));
        if (canConstructi && canConstructj)
        {
            if (hashIsInRange(Hash(map))) throw new Exception();//->WAが消えた
            //NoがYesと誤判定されてる
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
        //Console.WriteLine(canConstruct(countChari) && canConstruct(countCharj) ? "YES" : "NO");
    }
    static bool hashIsInRange(int hash)
    {
        int lower = 0;
        int upper = int.MaxValue;
        return lower <= hash && hash <= upper;
    }
    static int Hash(char[][] map) => string.Join("", map.Select(x => string.Join("", x))).GetHashCode();
    static bool canConstruct(int[][] countChar)
    {
        bool center = countChar.Length % 2 == 1;
        bool[] isUsed = new bool[countChar.Length];
        for (int i = 0; i < countChar.Length; i++)
        {
            if (isUsed[i]) continue;
            for (int j = i + 1; j < countChar.Length; j++)
            {
                if (isUsed[j]) continue;
                for (int k = 0; k < 26; k++)
                {
                    if (countChar[i][k] != countChar[j][k]) goto alphend;
                }
                isUsed[i] = true;
                isUsed[j] = true;
                break;
                alphend:;
            }
            if (center && !isUsed[i])
            {
                bool innnerCenter = countChar[i].Sum() % 2 == 1;
                int[] judge = countChar[i].OrderBy(x => x).SkipWhile(x => x == 0).ToArray();
                foreach (var item in judge)
                {
                    /*
                    if (last == 0) last = item;
                    else if (last == item) last = 0;
                    else if (innnerCenter)
                    {
                        last = 0;
                        innnerCenter = false;
                    }
                    else
                    {
                        goto end;
                    }*/
                    if (item % 2 != 0)
                    {
                        if (!innnerCenter) goto end;
                        innnerCenter = false;
                    }
                }
                isUsed[i] = true;
                center = false;
                end:;
            }
        }
        return isUsed.All(x => x);
    }
}