jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] X = new int[N];
            for (int i = 0; i < N; i++) {
                X[i] = in.nextInt();
            }

            IntListSorted list = new IntListSorted(N);
            for (int i = 0; i < N; i++) {
                list.add(X[i]);
            }

            int[] medians = new int[N];
            for (int i = 0; i < N; i++) {
                list.removeValue(X[i]);
                medians[i] = list.get((N - 2) / 2);
                list.add(X[i]);
            }

            for (int i = 0; i < N; i++) {
                System.out.println(medians[i]);
            }
        }
    }
}

class IntListSorted {
    private static final int EMPTY = -1;
    private int[] values;
    private int size;

    public IntListSorted(int capacity) {
        values = new int[capacity];
        clear();
    }

    public void clear() {
        size = 0;
    }

    public int size() {
        return size;
    }

    public boolean isEmpty() {
        return size() <= 0;
    }

    public boolean contains(int value) {
        return indexOf(value) != EMPTY;
    }

    public boolean add(int value) {
        values[size++] = value;
        for (int i = size - 1; i >= 1; i--) {
            if (values[i - 1] <= values[i]) {
                break;
            }
            swap(values, i - 1, i);
        }
        return true;
    }

    private void swap(int[] values, int i, int j) {
        int swap = values[i];
        values[i] = values[j];
        values[j] = swap;
    }

    public boolean removeValue(int value) {
        int index = indexOf(value);
        if (index == EMPTY) {
            return false;
        }
        remove(index);
        return true;
    }

    public int remove(int index) {
        int value = values[index];
        for (int i = index; i + 1 < size; i++) {
            values[i] = values[i + 1];
        }
        size--;
        return value;
    }

    public int get(int index) {
        return values[index];
    }

    public void add(int index, int value) {
        assert index <= size;
        for (int i = size - 1; i >= index; i--) {
            values[i + 1] = values[i];
        }
        size++;
        values[index] = value;
    }

    public int indexOf(int value) {
        int index = Arrays.binarySearch(values, 0, size, value);
        if (index < 0) {
            return EMPTY;
        }
        int index0 = index;
        for (;;) {
            index = Arrays.binarySearch(values, 0, index0, value);
            if (index < 0) {
                break;
            }
            index0 = index;
        }
        return index0;
    }

}
//  [java]


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> x = new ArrayList<>();
        ArrayList<Integer> xx = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            x.add(tmp);
            xx.add(tmp);
        }
        Collections.sort(xx);
        int r = xx.get(n / 2 - 1);
        int l = xx.get(n / 2);
        for (int i = 0; i < n; i++) {
            int tmp = x.get(i);
            int tmp3 = xx.indexOf(Integer.valueOf(tmp));
            int tmp4 = 0;
            if(tmp3 <= (n - 1) / 2) {
                tmp4 = l;
            } else if (tmp3 > (n - 1) / 2) {
                tmp4 = r;
            }
            System.out.println(tmp4);
        }
    }
}
//  [java]


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> x = new ArrayList<>();
        ArrayList<Integer> xx = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            x.add(tmp);
            xx.add(tmp);
        }
        Collections.sort(xx);
        for (int i = 0; i < n; i++) {
            int tmp = x.get(i);
            int tmp3 = xx.indexOf(Integer.valueOf(tmp));
            int tmp4 = 0;
            if(tmp3 <= (n - 1) / 2) {
                tmp4 = xx.get(((n - 1) / 2) + 1);
            } else if (tmp3 > (n - 1) / 2) {
                tmp4 = xx.get((n - 1) / 2);
            }
            System.out.println(tmp4);
        }
    }
}
//  [cpp]
#include <cstdio>
#include <cstring>
#include <algorithm>
#ifdef ONLINE_JUDGE
#define freopen(a, b, c)
#endif

typedef long long int ll;

namespace IPT {
  const int L = 1000000;
  char buf[L], *front=buf, *end=buf;
  char GetChar() {
    if (front == end) {
      end = buf + fread(front = buf, 1, L, stdin);
      if (front == end) return -1;
    }
    return *(front++);
  }
}

template <typename T>
inline void qr(T &x) {
  char ch = IPT::GetChar(), lst = ' ';
  while ((ch > '9') || (ch < '0')) lst = ch, ch=IPT::GetChar();
  while ((ch >= '0') && (ch <= '9')) x = (x << 1) + (x << 3) + (ch ^ 48), ch = IPT::GetChar();
  if (lst == '-') x = -x;
}

namespace OPT {
  char buf[120];
}

template <typename T>
inline void qw(T x, const char aft, const bool pt) {
  if (x < 0) {x = -x, putchar('-');}
  int top=0;
  do {OPT::buf[++top] = static_cast<char>(x % 10 + '0');} while (x /= 10);
  while (top) putchar(OPT::buf[top--]);
  if (pt) putchar(aft);
}

const int maxn = 2000005;

int n, x, y;
int MU[maxn], CU[maxn];

int main() {
  qr(n);
  for (int i = 1; i <= n; ++i) {
    qr(MU[i]);
  }
  memcpy(CU + 1, MU + 1, n * sizeof(int));
  std::sort(MU + 1, MU + 1 + n);
  x = MU[n >> 1]; y = MU[(n >> 1) + 1];
  for (int i = 1; i <= n; ++i) {
    qw((CU[i] <= x) ? y : x, '\n', true);
  }
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
  ll N;  cin >> N;
  VL X(N);
  rep(i,0,N){
    cin >> X[i];
  }
  VL sX(N);
  sX = X;
  sort(ALL(sX));

  rep(i,0,N/2){
    if(sX[N/2] == X[i]) cout << sX[N/2-1] << endl;
    else cout << sX[N/2] << endl;
  }
  rep(i,N/2,N){
    if(sX[N/2-1] == X[i]) cout << sX[N/2] << endl;
    else cout << sX[N/2-1] << endl;
  }
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
  ll N;  cin >> N;
  VL X(N,0); 
  rep(i,0,N){
    cin >> X[i];
  }

  rep(i,0,N){
    VL sX = X;
    sX.erase(sX.begin()+i);
    sort(ALL(sX));
    cout << sX[N/2-1] << endl;
  }
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> t = a;
	sort(t.begin(), t.end());
	int c = t[n / 2];
	int d = t[n / 2 - 1];
	rep(i, n) {
		if (a[i] == c) cout << d << endl;
		else cout << c << endl;
	}
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}
static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}

i32 nth (i32 *a, i32 n, i32 k) {
  i32 p = rand() % n;
  i32 pivot = a[p];
  a[p] = a[0];
  i32 assign = 0;
  i32 l = 1;
  i32 r = n;
  while (l < r) {
    if (a[l] == pivot) {
      l++;
    } else if (a[l] < pivot) {
      a[assign++] = a[l++];
    } else {
      i32 swap = a[--r];
      a[r] = a[l];
      a[l] = swap;
    }
  }
  for (i32 i = assign; i < l; ++i) a[i] = pivot;
  if (assign <= k && k < r) return pivot;
  return k < assign ? nth (a, assign, k) : nth (a + l, n - l, k - l);
}

void run (void) {
  i32 n = read_int();
  i32 *a = (i32 *) calloc (2 * n, sizeof (i32));
  i32 *b = a + n;
  for (i32 i = 0; i < n; ++i) {
    a[i] = b[i] = read_int();
  }
  i32 l = nth (b, n, n / 2 - 1);
  i32 r = 1000000000;
  for (i32 i = n / 2; i < n; ++i) r = r > b[i] ? b[i] : r;
  for (i32 i = 0; i < n; ++i) {
    print_int (a[i] <= l ? r : l);
    putchar ('\n');
  }
}

int main (void) {
  run();
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}
static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}

typedef i32  radix_type;

#define RADIX_WIDTH 10
const uint32_t radix_type_max = 30;
const uint32_t radix_type_begin = 0;
const uint32_t radix_width = RADIX_WIDTH;
const uint32_t radix_mask = (1 << RADIX_WIDTH) - 1;
#undef RADIX_WIDTH

static inline uint32_t radix_get_bit (radix_type v, uint32_t shift) {
  return v >> shift & radix_mask;
}

void radix_sort (radix_type *a, uint32_t n) {
  radix_type * const array = (radix_type *) calloc (4 * n, sizeof (radix_type));
  radix_type **bucket = (radix_type **) calloc (1 << radix_width, sizeof (radix_type *));
  uint32_t *len = (uint32_t *) calloc (2 << radix_width, sizeof (uint32_t));
  uint32_t *max_len = len + (1 << radix_width);
  for (uint32_t shift = radix_type_begin; shift < radix_type_max; shift += radix_width) {
    radix_type *p = array;
    memset (len, 0, sizeof (uint32_t) << (radix_width + 1));
    for (uint32_t i = 0; i < n; ++i) {
      uint32_t bit = radix_get_bit (a[i], shift);
      if (len[bit] == max_len[bit]) {
	for (uint32_t j = 0; j < len[bit]; ++j) {
	  p[j] = bucket[bit][j];
	}
	max_len[bit] = 2 * max_len[bit] + 1;
	bucket[bit] = p;
	p += max_len[bit];
      }
      bucket[bit][len[bit]++] = a[i];
    }
    for (uint32_t bit = 0, i = 0; bit < (1 << radix_width); ++bit) {
      for (uint32_t j = 0; j < len[bit]; ++j, ++i) {
	a[i] = bucket[bit][j];
      }
    }
  }
  free (array);
  free (bucket);
  free (len);
}

void run (void) {
  i32 n = read_int();
  i32 *a = (i32 *) calloc (2 * n, sizeof (i32));
  i32 *b = a + n;
  for (i32 i = 0; i < n; ++i) {
    a[i] = b[i] = read_int();
  }
  radix_sort (b, n);
  i32 l = b[n / 2 - 1];
  i32 r = b[n / 2];
  for (i32 i = 0; i < n; ++i) {
    print_int (a[i] <= l ? r : l);
    putchar ('\n');
  }
}

int main (void) {
  run();
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void split(int out[], char str[]);
int cmp(const void *p, const void *q);

int main(void) {
  int nums;
  char *tmp;
  int *list, *sorted;
  int rmed, lmed;
  tmp = (char *)malloc(sizeof(char) * 2000001);
  list = (int *)malloc(sizeof(int) * 200001);
  sorted = (int *)malloc(sizeof(int) * 200001);
  int i;
  scanf("%d\n", &nums);
  gets(tmp);
  split(list, tmp);
  memcpy(sorted, list, sizeof(int) * nums);
  qsort(sorted, nums, sizeof(int), cmp); // listをソート
  rmed = sorted[nums / 2];
  lmed = sorted[nums / 2 - 1]; // 正しい
  free(sorted);
  for (i = 0; i < nums; ++i) {
    if (list[i] <= lmed) {
      printf("%d\n", rmed);
    } else {
      printf("%d\n", lmed);
    }
  }
  free(tmp);
  free(list);
  return 0;
}

void split(int out[], char str[]) {
  int i;
  int out_i = 0, tmp_i = 0;
  char tmp[11] = {};
  for (i = 0; ; ++i) {
    if (str[i] == ' ') {
      out[out_i++] = atoi(tmp);
      memset(tmp, '\0', sizeof(tmp));
      tmp_i = 0;
    } else if (str[i] == '\0') {
      out[out_i] = atoi(tmp);
      break;
    } else {
      tmp[tmp_i++] = str[i];
    }
  }
}

int cmp(const void *p, const void *q) {
    return *(int*)p - *(int*)q;
}
//  [c]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int n;
    scanf("%d", &n);

    vector<int> x(n);
    rep(i, n) scanf("%d", &x[i]);

    vector<int> y(x);
    sort(y.begin(), y.end());

    int lo = y[n / 2 - 1];
    int hi = y[n / 2];

    rep(i, n) {
        int ans = (x[i] <= lo) ? hi : lo;
        printf("%d\n", ans);
    }
    return 0;
}
//  [c]
#include<stdio.h>
int a[200000],b[200000],k,n;
void quicksort(int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=b[a[(s+t)/2]];
    while(1){
      while(b[a[i]]<p)i++;
      while(p<b[a[j]])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int main(){
  scanf("%d",&n);
  for(k=0;k<n;k++){scanf("%d",&b[k]);a[k]=k;}
  quicksort(a,0,n-1);
  for(k=0;k<n;k++)printf("%d\n",a[k]<n/2?b[a[n/2]]:b[a[n/2-1]]);
}
//  [c]
#include<stdio.h>
void quicksort(int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=a[(s+t)/2];
    while(1){
      while(a[i]<p)i++;
      while(p<a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int main(){
  int a[200000],i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  quicksort(a,0,n-1);
  for(i=0;i<n;i++)printf("%d\n",i<n/2?a[n/2]:a[n/2-1]);
}
//  [javascript]
Main(myin());
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var sortedList = JSON.parse(JSON.stringify(list));
  sortedList.sort(function(a,b){
  	return a-b;
  });
  var output = new Array(N);
  if(sortedList[N/2-1] == sortedList[N/2]){
    output.fill(sortedList[N/2-1]);
  }else{
    for(var i = 0; i < N; i++){
      if(list[i] <= sortedList[N/2-1]){
         output[i] = sortedList[N/2];
      }else{
        output[i] = sortedList[N/2-1];
      }
    }
  }
  myout(myconv(output,9));
}
//  [javascript]


'use strict'

function main(input) {

    input = input.split('\n')
    const n = ~~input[0]
    const x = input[1].split(' ').map(v => ~~v)
    const x2 = x.slice(0).sort((a, b) => a - b)

    const mid = x2[n / 2]
    const mid2 = x2[n / 2 - 1]

    let ans = ''
    for (let i = 0; i < n; i++) {
        if (x[i] < mid) ans += mid+'\n'
        else ans += mid2+'\n'

    }

    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(s) {

  s = s.split('\n');

  const nums = s[1].split(' ').map(n => Number(n));

  const copy_nums = nums.slice(0);
  copy_nums.sort((a, b) => a - b);

  const med1 = copy_nums[copy_nums.length / 2];
  const med2 = copy_nums[(copy_nums.length / 2) - 1];

  const ans = [];

  for (const n of nums) {
    if (med1 > n)  ans.push(med1);
    if (med1 <= n) ans.push(med2);
  }

  console.log(ans.join('\n'));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
console.log((args=>{
  const [[N],X] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const _X = [].concat(X).sort((a,b)=>a-b);
  const M1 = _X[N/2-1], M2 = _X[N/2];
  const m = [];
  for ( let i = 0; i < N; i++ ) {
    if ( X[i] <= M1 ) m.push(M1); else m.push(M2);
  }
  return m.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
console.log((args=>{
  const [[N],...X] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const _X = [].concat(X).sort((a,b)=>a-b);
  const M1 = _X[N/2-1], M2 = _X[N/2];
  const m = [];
  for ( let i = 0; i < N; i++ ) {
    if ( X[i] < M1 ) m.push(M1); else m.push(M2);
  }
  return m.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var check = JSON.parse(JSON.stringify(list));
	check.sort(function(a,b){
		return a - b;
	});
	var output = new Array(N);
	var max1 = check[(N / 2)];
	var max2 = check[N / 2 - 1];
	for(var i = 0; i < N; i++){
		if(max2 == max1){
			output[i] = max1;
		}else{
			if(max1 == list[i]){
				output[i] = max2;
			}else{
				output[i] = max1;
			}
		}
	}
	myout(myconv(output,9));
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	n := getInt()
	xs := getIntSlice(n)

	a, b := func() (int, int) {
		tmp := make([]int, n)
		copy(tmp, xs)
		sort.Ints(tmp)
		return tmp[n/2-1], tmp[n/2]
	}()

	ans := make([]string, n)
	for i, x := range xs {
		if x <= a {
			ans[i] = strconv.Itoa(b)
		} else {
			ans[i] = strconv.Itoa(a)
		}
	}

	fmt.Println(strings.Join(ans, "\n"))
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	scan_init()
	n := scanInt()
	x := make([]int, n)
	y := make([]int, n)
	// sumX := make([]int, n)
	for i:= 0; i<n; i++ {
		p := scanInt()
		x[i] = p
		y[i] = p
	}
	// fmt.Println("aa", n/2)
	sort.Ints(y)
	merginLeft := y[(n/2)-1]
	merginRight := y[(n/2)]
	fmt.Println(merginLeft, merginRight)
	for i:= 0; i<n; i++ {
		if x[i]<= merginLeft {
			fmt.Println(merginRight)
		} else {
			fmt.Println(merginLeft)
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	nums := make([]int, n)
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
		m[i+1] = nums[i]
	}
	sort.Ints(nums)
	l := nums[n/2-1]
	r := nums[n/2]
	for i := 1; i <= n; i++ {
		v := m[i]
		if l < v {
			fmt.Println(l)
		} else {
			fmt.Println(r)
		}
	}
}
//  [ruby]
n = gets.to_i
numbers = gets.split.map(&:to_i)

sorted_numbers = numbers.sort
left_median = sorted_numbers[(n - 1) / 2]
right_median = sorted_numbers[((n - 1) / 2) + 1]


answers = numbers.map { |number|
  number <= left_median ? right_median : left_median
}

puts answers
//  [ruby]
N = gets.chomp.to_i
X = gets.chomp.split().map(&:to_i)
sorted_X = X.sort

ml = sorted_X[sorted_X.length/2 - 1]
mr = sorted_X[sorted_X.length/2]

X.each do |x|
  puts(x <= ml ? mr : ml)
end
//  [ruby]
n = gets.to_i
x = gets.chomp.split(" ").map(&:to_i)
sorted = x.sort
down = sorted[(n/2)-1]
up = sorted[n/2]
n.times do |i|
  if x[i] >= up
    puts down
  else
    puts up
  end
end
//  [ruby]
n = gets.to_i
x = gets.split.map(&:to_i)
h = Hash.new(0)
x.each do |y|
  h[x] += 1
end
x.each do |y|
  a1 = x.sort[n / 2 - 1]
  a2 = x.sort[n / 2]
  if y <= a1
    puts a2
  else
    puts a1
  end
end
//  [ruby]
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, x_list = gets_n_and_i_list

N.times do |i|
  tmp = x_list.dup
  tmp.delete_at(i)
  tmp.sort!
  puts tmp[N/2 - 1]
end
//  [ruby]
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
x=get_i
x_sort=x.sort
n.times do|i|
  k=x_sort.index(x[i])
  if k+1<=n/2
    puts x_sort[(n)/2]
  else
    puts x_sort[(n)/2-1]
  end
end
//  [rust]
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let (n, xs) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        let n = sc.next();
        (n, sc.vec::<u64>(n))
    };
    let mut vs = xs.iter().cloned().collect::<Vec<_>>();
    vs.sort();
    let stdout = io::stdout();
    let mut stdout = BufWriter::new(stdout.lock());
    let x1 = vs[n / 2 - 1];
    let x2 = vs[n / 2];
    for j in 0..n {
        if x1 < xs[j] {
            writeln!(stdout, "{}", x1).unwrap();
        } else {
            writeln!(stdout, "{}", x2).unwrap();
        }
    }
    stdout.flush().unwrap();
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}
//  [rust]
use std::io::{stdout, BufWriter, Write};
use std::thread;

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_x: Vec<i64> = input.map(|s| s.parse().unwrap()).collect();

    let mut y = in_x.clone();
    y.sort();
    let x1 = y[in_n as usize / 2 - 1];
    let x2 = y[in_n as usize / 2];

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    for x in in_x {
        writeln!(out, "{}", if x <= x1 { x2 } else { x1 }).unwrap();
    }
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}
//  [rust]
use std::io::{stdout, BufWriter, Write};
use std::str::FromStr;
use std::thread;

fn run() {
    let stdin = std::io::stdin();
    let mut input = String::new();
    stdin.read_line(&mut input).ok();

    let in_n: i64 = input.trim().parse().unwrap();

    let mut input = String::new();
    stdin.read_line(&mut input).ok();
    let in_x: Vec<u64> = input
        .split_whitespace()
        .map(|s| u64::from_str(s).unwrap())
        .collect();

    let mut y = in_x.clone();
    y.sort();
    let x1 = y[in_n as usize / 2 - 1];
    let x2 = y[in_n as usize / 2];

    let mut out = stdout();
    let mut out = BufWriter::new(out.lock());
    for x in in_x {
        writeln!(out, "{}", if x <= x1 { x2 } else { x1 }).unwrap();
    }
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}
//  [rust]
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::Ordering;
use std::collections::HashMap;

#[fastout]
fn main() {
  input! {
    n: usize,
    vals: [usize;n]
  }

  let mut vis = vals
  .into_iter()
  .enumerate()
  .map(|(i, v)| (i, v))
  .collect::<Vec<(usize, usize)>>();
  vis.sort_by(|b,a| {
    let v = b.1.cmp(&a.1);
    if v == Ordering::Equal {
      b.0.cmp(&a.0)
    } else {
      v
    }
  });
  
  let mut map:Vec<usize> = vec![0;n];
  for i in 0..n {
    map[vis[i].0] = i;
  }
  
  for i in 0..n {
    let mut c_vals = vis.clone();
    c_vals.remove(map[i]);
    println!("{}", c_vals[n/2 - 1].1);
  }
}
//  [rust]
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::Ordering;
use std::collections::HashMap;

#[fastout]
fn main() {
  input! {
    n: usize,
    vals: [usize;n]
  }

  let mut vis = vals
  .into_iter()
  .enumerate()
  .map(|(i, v)| (i, v))
  .collect::<Vec<(usize, usize)>>();
  vis.sort_by(|b,a| {
    let v = b.1.cmp(&a.1);
    if v == Ordering::Equal {
      b.0.cmp(&a.0)
    } else {
      v
    }
  });
  
  let mut map:HashMap<usize, usize> = HashMap::new();
  for i in 0..n {
    map.insert(vis[i].0, i);
  }
  
  for i in 0..n {
    let ti = *map.get(&i).unwrap();
    let v = vis.remove(ti);
    println!("{}", vis[n/2 - 1].1);
    vis.insert(ti, v);
  }
}
//  [rust]
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
  input! {
    n: usize,
    vals: [usize;n]
  }
  
  for i in 0..n {
    let mut c_vals = vals.clone();
    c_vals.remove(i);
    c_vals.sort();
    println!("{}", c_vals[n/2 - 1]);
  }
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryX = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let b = n / 2 - 1
    var aryXSorted = aryX.sorted(by: >)
    let median = aryXSorted[b]
    aryXSorted.remove(at: b)
    let secondMedian = aryXSorted[b]
    
    for i in aryX {
        print(i < median ? median: secondMedian)
    }
}
main()
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}

/*************** メインプログラム ***************/

let N = readInt()!
let X = readIntSplit(by: " ")
let sortedX = X.sorted()
var center = sortedX[N/2]
for i in X {
    if i < center {
        print(center)
    } else {
        print(sortedX[N/2-1])
    }
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryX = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let b = n / 2 - 1
    var aryXSorted = aryX.sorted(by: >)
    let median = aryXSorted[b]
    aryXSorted.remove(at: b)
    let secondMedian = aryXSorted[b]
    
    for i in 0..<n {
        print(aryX[i] == median ? secondMedian: median)
    }
}
main()
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryX = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let b = n / 2 - 1
    
    for i in 0..<n {
        var aryXSorted = aryX
        aryXSorted.remove(at: i)
        aryXSorted.sort(by: >)
        
        print(aryXSorted[b])
    }
}
main()
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}

/*************** メインプログラム ***************/

let N = readInt()!
let X = readIntSplit(by: " ")
let sortedX = X.sorted()
var center = sortedX[N/2]
for i in X {
    if i > center {
        center = sortedX[N/2-1]
    }
    print(center)
}
//  [typescript]
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function(line: string) {
  lines.push(line);
});
reader.on("close", function() {
  var valueN: number = Number(lines[0].split(" ")[0]);

  var listX: number[] = lines[1]
    .split(" ")
    .map(function(value: string): number {
      return Number(value);
    });
  var sortedList: number[] = new Array(valueN);
  listX.forEach(x => {
    sortedList.push(x);
  });
  sortedList.sort((n1, n2) => n1 - n2);

  var smallMedian: number = sortedList[valueN / 2 - 1];
  var largeMedian: number = sortedList[valueN / 2];

  for (var i: number = 0; i < valueN; i++) {
    if (listX[i] <= smallMedian) {
      console.log(largeMedian);
    } else {
      console.log(smallMedian);
    }
  }
});
//  [typescript]
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');
  const params2 = lines[1].split(' ');

  const n = parseInt(params1[0]);
  const x = params2.map(x => parseInt(x));

  const y = sort(x);

  const l = Math.floor(n / 2);
  const y1 = y[l - 1];
  const y2 = y[l];

  x.forEach(a => {
    const b = (a <= y1) ? y2 : y1;
    console.log(b);
  });
}

function sort(a: number[]): number[] {
  let b = [...a];
  b.sort((x, y) => x - y);
  return b
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');
  const params2 = lines[1].split(' ');

  const n = parseInt(params1[0]);
  const x = params2.map(x => parseInt(x));

  const y = sort(x);

  const l = Math.floor(n / 2);
  const y1 = y[l - 1];
  const y2 = y[l];

  x.forEach(a => {
    const b = (a <= y1) ? y2 : y1;
    console.log(b);
  });
}

function sort(a: number[]): number[] {
  let b: number[] = [];
  a.forEach(n => {
    b.push(n);
  });

  b.sort((x, y) => x - y);
  
  return b
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');
  const params2 = lines[1].split(' ');

  const n = parseInt(params1[0]);
  const x = params2.map(x => parseInt(x));

  const y = sort(x);

  const l = Math.floor(n / 2);
  const y1 = y[l - 1];
  const y2 = y[l];

  x.forEach(a => {
    const b = (a <= y1) ? y2 : y1;
    console.log(b);
  });
}

function sort(a: number[]): number[] {
  let b: number[] = [];
  if (a.length !== 0) {
    const x = a[0];

    const a1 = a.slice(1).filter(n => n <= x);
    const a2 = a.slice(1).filter(n => n > x);

    sort(a1).forEach(n => {
      b.push(n);
    });
    b.push(x);
    sort(a2).forEach(n => {
      b.push(n);
    });
  }
  return b
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');
  const params2 = lines[1].split(' ');

  const n = parseInt(params1[0]);
  const x = params2.map(x => parseInt(x));

  let a1 = Math.min(x[0], x[1]);
  let a2 = Math.max(x[0], x[1]);

  if (n >= 4) {
    const b1 = Math.min(x[2], x[3]);
    const b2 = Math.max(x[2], x[3]);
    let a3: number;
    let a4: number;
    if (a2 <= b1) { // aabb
      a3 = b1;
      a4 = b2;
    } else if (a1 <= b1 && b1 <= a2) { // abab
      a3 = a2;
      a2 = b1;
      a4 = b2;
    } else if (a1 <= b1 && b2 <= a2) { // abba
      a4 = a2;
      a2 = b1;
      a3 = b2;
    } else if (b1 <= a1 && a2 <= b2) { // baab
      a3 = a2;
      a2 = a1;
      a1 = b1;
      a4 = b2;
    } else if (b1 <= a1 && a1 <= b2) { // baba
      a4 = a2;
      a2 = a1;
      a1 = b1;
      a3 = b2;
    } else { // bbaa
      a3 = a1;
      a4 = a2;
      a1 = b1;
      a2 = b2;
    }
    // a1 <= a2 <= a3 <= a4

    if (n >= 6) {
      for (let i = 4; i < n; i++) {
        const b = x[i];
        if (b <= a1) {
          a4 = a3;
          a3 = a2;
          a2 = a1;
          a1 = b;
        } else if (a1 < b && b <= a2) {
          a4 = a3;
          a3 = a2;
          a2 = b;
        } else if (a2 < b && b <= a3) {
          a4 = a3;
          a3 = b;
        } else if (a3 < b && b <= a4) {
          a4 = b;
        }
      }
    }

    a1 = a2;
    a2 = a3;
  }

  for (let i = 0; i < n; i++) {
    const b = (x[i] <= a1) ? a2 : a1;
    console.log(b);
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));