CodeEff/ECCO huggingface dataset:
# Original solution
import sys
import bisect
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))
    X = list(map(int, input().split()))
    X_s = sorted(X)

    for i in range(n):
        idx = bisect.bisect_left(X_s, X[i])
        if idx <= n // 2 - 1:
            print((X_s[n // 2]))
        else:
            print((X_s[n // 2 - 1]))


if __name__ == '__main__':
    resolve()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    X = list(map(int, input().split()))
    for i in range(n):
        x = X[i]
        X[i] = [i, x]
    X_s = sorted(X, key=lambda x: x[1])

    res = [0] * n
    for i in range(n):
        idx, _ = X_s[i]
        if i < n // 2:
            res[idx] = X_s[n // 2][1]
        else:
            res[idx] = X_s[n // 2 - 1][1]

    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()
# Original solution
N = int(eval(input()))
li = list(map(int,input().split()))
lia = li[:]
for i in range(N) :
    del lia[i]
    lia.sort()
    ave = int((N-2)/2)
    a = lia[ave]
    lia = li[:]
    print(a)

# Optimized solution
N = int(eval(input()))
li = list(map(int,input().split()))
lia = li[:]
lia.sort()
index1 = int(N/2)
index2 = int((N-2)/2)
ave1 = lia[index2]
ave2 = lia[index1]
for i in range(N) :
    if li[i] <= ave1 :
        print(ave2)
    else :
        print(ave1)
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))
mid = N // 2 - 1
for i in range(N):
    tmp = X[:i]
    tmp.extend(X[i+1:])
    tmp.sort()
    print((tmp[mid]))

# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
tmp = X[:]
tmp.sort()
mid = N // 2 - 1
low = tmp[mid]
high = tmp[mid + 1]
all = sum(tmp)
for a in X:
    if a <= low:
        print(high)
    else:
        print(low)
# Original solution
from statistics import median

N = int(eval(input()))
X = list(map(int, input().split()))

for i in range(N):
    Xx = [X[k] for k in range(N) if k != i]
    print((median(Xx)))


# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))

Xs = sorted(X)
median1 = Xs[int(N/2)-1]
median2 = Xs[int(N/2)]

for i in range(N):
    if X[i] >= median2:
        print(median1)
    else:
        print(median2)
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))
sort_X = sorted(X)

for i in range(N):
    copy_X = sort_X.copy()
    copy_X.remove(X[i])
    
    print((copy_X[(N-1)//2]))

# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
sort_X = sorted(X)
a = sort_X[N//2-1]
b = sort_X[N//2]
for i in range(N):
    if X[i] < b:
        print(b)
    else:
        print(a)
# Original solution
import statistics
 
N = int(eval(input()))
X = list(map(int, input().split()))
 
for i in range(len(X)):
    print((statistics.median(X[:i]+X[i+1:])))

# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
Y = X[:]
Y = sorted(Y)

med1 = Y[N // 2 - 1]
med2 = Y[N // 2]

for x in X:
    if x < med2:
        print(med2)
    else:
        print(med1)
# Original solution
n = int(eval(input()))
x = [int(i) for i in input().split()]

y = [[x[i], i] for i in range(n)]
y.sort()

z = [0 for i in range(n)]
for i in range(n):
    z[y[i][1]] = (y[:i]+y[i+1:])[(n+1)//2-1][0]

for i in range(n):
    print((z[i]))

# Optimized solution
n = int(eval(input()))
x = [int(i) for i in input().split()]

y = sorted(x)
med1 = y[n//2-1]
med2 = y[n//2]

for i in range(n):
    if x[i] <= med1:
        print(med2)
    else:
        print(med1)
# Original solution
N = int(eval(input()))
X = [int(_) for _ in input().split()]

X2 = sorted(X)
r = X2[N // 2 ]
l = X2[N // 2 -1]

for i in range(N):
    if X2.index(X[i]) < N // 2:
        print(r)
    else:
        print(l)

# Optimized solution
N = int(eval(input()))
X = [int(_) for _ in input().split()]

X2 = sorted(X)
r = X2[N // 2 ]
l = X2[N // 2 -1]

for i in range(N):
    if X[i] <  r:
        print(r)
    else:
        print(l)
# Original solution
import copy

n = int(eval(input()))
x = list(map(int,input().split()))
base = copy.deepcopy(x)
base_1 = copy.deepcopy(x)
base.sort()
base_1.sort()

for i in range(n):
  a_l = base.index(x[i])
  a_u = base_1.index(x[i])
  
  if a_l == (n-1)-a_u:
    if n//2 > a_l:
      ans = base[n//2]
    elif n//2 <= a_l:
      ans = base[n//2-1]
      
  else:
    if (a_l <= n//2-1) and (n//2 <= a_u):
      ans = base[a_l]
    elif a_u <= n//2 - 1:
      ans = base[n//2]
    elif n//2 <= a_l:
      ans = base[n//2 - 1]
      
  print(ans)

# Optimized solution
import copy

n = int(eval(input()))
x = list(map(int,input().split()))
key = {}
base = copy.deepcopy(x)
base.sort()

for i in range(n):

  if n//2 > i:
    ans = base[n//2]
  elif n//2 <= i:
    ans = base[n//2-1]
   
  if not ("key" + str(base[i]) in key):
    key["key" + str(base[i])] = ans
    
for i in range(n):
  print((key["key" + str(x[i])]))
# Original solution
import statistics


n = int(eval(input()))
x = [int(_) for _ in input().split()]
m1 = statistics.median_low(x)
m2 = statistics.median_high(x)
for i in range(n):
    if x[i] <= m1:
        print(m2)
    else:
        print(m1)


# Optimized solution
n = int(eval(input()))
x = [int(_) for _ in input().split()]
l = sorted(x)
m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(n):
    if x[i] <= m1:
        print(m2)
    else:
        print(m1)
# Original solution
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  for i in range(N):
    T=copy.copy(Y)
    T.remove(X[i])
    print((T[t-1]))
  return 

main()

# Optimized solution
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  ans1=Y[t-1]
  ans2=Y[t]
  median=ans1+ans2
  for i in range(N):
    s=X[i]
    if s==ans1:
      print(ans2)
    elif s==ans2:
      print(ans1)
    elif  2*s<median:
      print(ans2)
    elif 2*s>median:
      print(ans1)
  return 

main()
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

for i in range(n):
  t=x[:i]+x[i+1:]
  t.sort()
  print((t[(n-1)//2]))

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))
t=sorted(x)
right=t[n//2]
left=t[n//2-1]

for i in x:
  if i <= left:
    print(right)
  elif i >= right:
    print(left)
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))
Xc = X.copy()
Xc.sort()

for i in range(N):
    ind = Xc.index(X[i])
    if ind < (N // 2):
        print((Xc[N // 2]))
    else:
        print((Xc[N // 2 - 1]))

# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
Xc = X.copy()
Xc.sort()

Xcmed = Xc[N//2]

for i in range(N):
    if X[i] < Xcmed:
        print((Xc[N // 2]))
    else:
        print((Xc[N // 2 - 1]))
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))
Xc = X.copy()
Xc.sort()

Xcmed = Xc[N//2]

for i in range(N):
    if X[i] < Xcmed:
        print((Xc[N // 2]))
    else:
        print((Xc[N // 2 - 1]))


# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
Xc = X.copy()
Xc.sort()

d = N // 2
dn = Xc[d]

for i in range(N):
    if X[i] < dn:
        print((Xc[d]))
    else:
        print((Xc[d-1]))
# Original solution
from statistics import median

N = int(eval(input()))
data = list(map(int, input().split(' ')))

for i in range(len(data)):
    temp = [x for j,x in enumerate(data) if j != i]
    print((median(temp)))

# Optimized solution
N = int(eval(input()))
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

c1 = sorteddata[N // 2]
c2 = sorteddata[N // 2 - 1]

for i in range(N):
    if (data[i] < c1):
        print(c1)
    else:
        print(c2)
# Original solution
n=int(eval(input()))
arr=[int(x) for x in input().split()]
for i in range(n):
    a = arr[:i] + arr[i+1:]
    a.sort()
    index = int((n-1)/2)
    print((a[index]))


# Optimized solution
n=int(eval(input()))
arr=[int(x) for x in input().split()]
sorted_arr = sorted(arr)
l = sorted_arr[n//2 -1]
r = sorted_arr[n//2]
for x in arr:
    if x >= r:
        print(l)
    else:
        print(r)
# Original solution
N = int(eval(input()))
X = list(map(int,input().split()))
sortedX = sorted(X)

for x in X:
    if sortedX.index(x) <= N//2 -1:
        print((sortedX[N//2]))
    else:
        print((sortedX[N//2 -1]))

# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))
sortedX = sorted(X)

for x in X:
    if sortedX[N//2 -1] >= x:
        print((sortedX[N//2]))
    else:
        print((sortedX[N//2 -1]))
# Original solution
def resolve():
	n=int(eval(input()))
	x=list(map(int,input().split()))
	for i in x:
		s=sorted(x)
		s.remove(i)
		print((s[(n-2)//2]))
	
resolve()

# Optimized solution
def resolve():
	n=int(eval(input()))
	x=list(map(int,input().split()))
	s=sorted(x)
	m=s[(n-2)//2]
	for i in x:
		ans=s[(n-2)//2+1] if i<=m else m
		print(ans)
	
resolve()
# Original solution
N = int( eval(input()))
Xs = list(map(int, input().split()))

for i,x in enumerate(Xs):
    arr = Xs[:i] + Xs[i+1:]
    arr.sort(reverse=True)
    m = int(N/2)-1
    print((arr[m]))

# Optimized solution
N = int(eval(input()))
Xs = list(map(int, input().split()))
s = sorted(Xs)
a = s[N//2-1]
b = s[N//2]
for x in Xs:
    if x < b:
        print(b)
    else :
        print(a)
# Original solution
if __name__ == '__main__':
    N = int(eval(input()))
    X = list(map(int, input().split()))
    x = sorted(X[:])
    for i in range(N):
        _x = x[:]
        _x.remove(X[i])
        print((_x[int(N/2-1)]))


# Optimized solution
if __name__ == '__main__':
    N = int(eval(input()))
    X = list(map(int, input().split()))
    x = sorted(X[:])
    min_median = x[int(N/2-1)]
    max_median = x[int(N/2)]
    for i in range(N):
        if X[i] <= min_median:
            print(max_median)
        else:
            print(min_median)
# Original solution
n=int(eval(input()))
x=list(map(int,input().split()))
l=len(x)
xs=sorted(x)
m=xs[l//2-1]
M=xs[l//2]
for i in range(l):
  print((m if x[i]>m else M))

# Optimized solution
n=int(eval(input()))
x=list(map(int,input().split()))
l=len(x)
s=sorted(x)
m=s[l//2-1]
M=s[l//2]
for i in range(l):
  print((m if x[i]>m else M))
# Original solution
n = int(eval(input()))

A = list(map(int, input().split()))

for i in range(n):
    B = A[:i] + A[i+1:]
    B = sorted(B)
    print((B[(n)//2-1]))

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))

B = sorted(A)

median_a = B[n//2 - 1]
median_b = B[n//2]
# print(median_a, median_b)

for i in A:
    if i <= median_a:
        print(median_b)
    else:
        print(median_a)
# Original solution
import math
n = int(eval(input()))
X = list(map(int,input().split()))
x = sorted(X)

left = x[math.floor((n-1)/2)]
right = x[math.ceil((n-1)/2)]

for a in X:
    i = x.index(a)
    if i < (n-1)/2:
        print(right)
    else:
        print(left)

# Optimized solution
import math
n = int(eval(input()))
X = list(map(int,input().split()))
x = sorted(X)

left = x[math.floor((n-1)/2)]
right = x[math.ceil((n-1)/2)]

for a in X:
    if a < right:
        print(right)
    else:
        print(left)
# Original solution
N = int(eval(input()))
X = [int(i) for i in input().split()]
for i in range(N):
    x = [int(X[j]) for j in range(N) if i != j]
    x.sort()
    print((x[(N - 1) // 2]))


# Optimized solution
N = int(eval(input()))
X = [int(i) for i in input().split()]
x = sorted(X)
n = N // 2
for i in range(N):
    if X[i] < x[n]:
        print((x[n]))
    else:
        print((x[n - 1]))
# Original solution
N = int(eval(input()))
n = (N//2) - 1
X = list(map(int,input().split()))
import copy
for i in range(N):
    Y = copy.deepcopy(X)
    Y.pop(i)
    Y.sort()
    ans = Y[n]
    print(ans)

# Optimized solution
N = int(eval(input()))
n = (N//2) - 1
X = list(map(int,input().split()))
import copy
Y = copy.deepcopy(X)
Y.sort()
a = Y[n]
b = Y[n+1]
for i in range(N):
    ans = a
    if X[i] <= a:
        ans = b
    print(ans)
# Original solution
import copy

n = int(eval(input()))
l = list(map(int,input().split()))
p = n//2

for i in range(n):
    tmp = copy.copy(l)
    tmp[i] = 0
    tmp.sort()
    print((tmp[p]))

# Optimized solution
import copy

n = int(eval(input()))
l = list(map(int,input().split()))
p1 = n//2
p2 = n//2-1
ans = copy.copy(l)
ans.sort()

for i in l:
    if i >= ans[p1]:
        print((ans[p2]))
    else:
        print((ans[p1]))
# Original solution
n  = int(eval(input()))
x = list(map(int, input().split()))
x_sorted = sorted(x)
for i in range(n):
    if x[i] <= x_sorted[n // 2 - 1]:
        print((x_sorted[n // 2]))
    else:
        print((x_sorted[n // 2 - 1]))

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))

x_sorted = sorted(x)

mL = (n - 1) // 2
mR = mL + 1

anss = []
for i in range(n):
    if x[i] <= x_sorted[mL]:
        anss.append(x_sorted[mR])
    else:
        anss.append(x_sorted[mL])
for ans in anss:
    print(ans)
# Original solution
N=int(eval(input()))
X=list(map(int,input().split()))

Median_i=N//2-1

for i in range(N):
    X_=X[:]
    del X_[i]
    X_.sort()
    print((X_[Median_i]))

# Optimized solution
N=int(eval(input()))
X=list(map(int,input().split()))

Median_1_i=N//2-1
Median_2_i=N//2

X_=X[:]
X_.sort(reverse=True)
Median_1=X_[Median_1_i]
Median_2=X_[Median_2_i]

for x in X:
    if x<Median_1:
        print(Median_1)
    else:
        print(Median_2)
# Original solution
n=int(eval(input()))
x=list(map(int,input().split()))

y=sorted(x)

xn=y[n//2-1]
xnp=y[n//2]

for i in range(n):
    if x[i]>xn:
        print(xn)
    else:
        print(xnp)

# Optimized solution

n=int(eval(input()))
x=list(map(int,input().split()))

y=sorted(x)

n2=n//2
y1=y[n2-1]
y2=y[n2]
for i in range(n):
    if x[i]<=y1:
        print(y2)
    else:
        print(y1)
# Original solution
n=int(eval(input()))
x=list([int(x) for x in input().split()])
mi = int(n/2)-1
sx=x[:]
sx.sort()
for item in x:
    cx=sx[:]
    cx.remove(item)
    print((cx[mi]))

# Optimized solution
n=int(eval(input()))
x=list([int(x) for x in input().split()])
mi = n//2 - 1
sx=sorted(x)
for item in x:
    if item > sx[mi]:
        print((sx[mi]))
    else:
        print((sx[mi+1]))
# Original solution
n = int(eval(input()))
xlist = [int(x) for x in input().split()]
sxlist = sorted(xlist)
for i in range(n):
    if sxlist.index(xlist[i]) < n/2:
        print((sxlist[int(n/2)]))
    else:
        print((sxlist[int(n/2)-1]))

# Optimized solution
n = int(eval(input()))
xlist = [int(x) for x in input().split()]
sxlist = sorted(xlist)
mid = sxlist[int(n/2)]
mid2 = sxlist[int(n/2)-1]
for i in range(n):
    if xlist[i] < mid:
        print(mid)
    else:
        print(mid2)
# Original solution
from statistics import median_low, median_high

n = int(eval(input()))
xs = list(map(int, input().split()))

m1, m2 = median_low(xs), median_high(xs)

medians = [m2 if x < m2 else m1 for x in xs]
print(('\n'.join(map(str, medians))))

# Optimized solution
n = int(eval(input()))
xs = list(map(int, input().split()))
 
ys = list(sorted(xs))
m1 = ys[n//2 - 1]
m2 = ys[n//2]
 
medians = [m2 if x < m2 else m1 for x in xs]
print(('\n'.join(map(str, medians))))
# Original solution
N = int(eval(input()))
x = list(map(int, input().split()))

for i in range(N):
    X = sorted(x[:i] + x[i+1:])
    print((X[(N-1)//2]))


# Optimized solution
N = int(eval(input()))
x = list(map(int, input().split()))
sx = sorted(x)
a = sx[N//2-1]
b = sx[N//2]

for c in x:
    if c <= a:
        print(b)
    else:
        print(a)
# Original solution
N=int(eval(input()))
X=list(map(int,input().split()))

s=[]
for i in range(N):
    s=sorted(X[:i]+X[i+1:])
    print((s[N//2-1]))

# Optimized solution
N=int(eval(input()))
X=list(map(int,input().split()))
S=sorted(X)
b=S[N//2]
a=S[(N//2)-1]
for i in X:
    print((b if i<b else a))
# Original solution
n = int(eval(input()))
x = list(map(int, input().split(" ")))

x_sorted = sorted(x)
samples = (x_sorted[n//2], x_sorted[n//2-1])
for x_i in x:
	print((samples[x_sorted.index(x_i)//(n//2)]))

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split(" ")))

x_sorted = sorted(x)
for x_i in x:
	print(((x_sorted[n//2-1], x_sorted[n//2])[x_i < x_sorted[n//2]]))
# Original solution
N = int(eval(input()))
numbers_r = tuple(map(int, input().split(' ')))
numbers_s = sorted(numbers_r)

med_high = numbers_s[N // 2]
med_low = numbers_s[N // 2 - 1]

for number in numbers_r:
    if number == med_low:
        print(med_high)
    elif number == med_high:
        print(med_low)
    elif number < med_low:
        print(med_high)
    elif number > med_high:
        print(med_low)


# Optimized solution
N = int(eval(input()))
numbers_r = tuple(map(int, input().split(' ')))
numbers_s = sorted(numbers_r)

med_high = numbers_s[N // 2]
med_low = numbers_s[N // 2 - 1]

for number in numbers_r:
    if number <= med_low:
        print(med_high)
    else:
        print(med_low)
# Original solution
import copy
N = int(eval(input()))
X = [int(i) for i in input().split()]
Y = copy.deepcopy(X)
Y.sort()

ML, MH = Y[N//2 - 1], Y[N//2]
for i in range(N):
    if X[i] >= MH:
        print(ML)
    else:
        print(MH)

# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    X = [int(x) for x in input().split()]
    Xsub = sorted(X)
    midl, midr = Xsub[(N - 1) // 2], Xsub[N // 2]
    ans = [0] * N
    for i, x in enumerate(X):
        if x <= midl: ans[i] = midr
        else: ans[i] = midl
    print(*ans, sep="\n")

    return 0

if __name__ == "__main__":
    solve()
# Original solution
import copy
n=int(eval(input()))
x=list(map(int,input().split()))

for i in range(n):
    y=copy.copy(x)
    del y[i]
    y.sort()
    print((y[n//2-1]))


# Optimized solution
n=int(eval(input()))
x=list(map(int,input().split()))
y=x.copy()
y.sort()
cr=y[n//2]
cl=y[n//2-1]

for i in range(n):
    if x[i]<=cl:
        print(cr)
    elif x[i]>=cr:
        print(cl)
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

def median(x, i):
    x = sorted(x)
        
    return(x[i])

def algo(x):
    l = len(x)
    t = (l + 1) // 2
    while True:
        p = x[len(x) // 2]
        a = []
        b = []
        for i in x:
            if i <= p:
                a.append(i)
            else:
                b.append(i)
        if len(a) == 0:
            return median(b, t - 1)
        elif len(b) == 0:
            return median(a, t - 1)
        elif len(a) >= t:
            x = a
        else:
            x = b
            t = t - len(a)


for i in range(n):
    a = x.pop(i)
    print((algo(x)))
    x.insert(i, a)

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))

y = sorted(x)

for i in x:
    if i < y[len(y) // 2]:
        print((y[len(y) // 2]))
    else:
        print((y[len(y) // 2 - 1]))
# Original solution
n = int(eval(input()))
x = [int(i) for i in input().split()]

for i in range(n):
    y = x[:i] + x[i+1:]
    y.sort()
    print((y[n//2-1]))


# Optimized solution
n = int(eval(input()))
x = [int(i) for i in input().split()]
y = sorted(x)
a , b = y[n//2-1], y[n//2]
for i in x:
    if i > a:
        print(a)
    else:
        print(b)
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))

c = N // 2
x = sorted(X)
for v in X:
	if x.index(v) < c:
		print((x[c]))
	else:
		print((x[c - 1]))


# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))

c = N // 2
x = sorted(X)
for v in X:
	if v < x[c]:
		print((x[c]))
	else:
		print((x[c - 1]))
# Original solution
n = int(eval(input()))
X = [int(i) for i in input().split()]
sX = sorted(X)
r,l = sX[n//2],sX[n//2-1]
if r != l:
    for x in X:
        if x<=l: print(r)
        else: print(l)
else:
    for _ in range(n): print(l)


# Optimized solution
n = int(eval(input()))
X = [int(i) for i in input().split()]
sX = sorted(X)
r,l = sX[n//2],sX[n//2-1]
for x in X:
    if x<=l: print(r)
    else: print(l)
# Original solution
n=int(eval(input()))
x=[int(i) for i in input().split()]
for i in range(n):
    A=x[0:i]+x[i+1:]
    A.sort()
    half=n//2
    print((A[n-half-1]))

# Optimized solution
n=int(eval(input()))
x=[int(i) for i in input().split()]
A=sorted(x)
b=A[n//2-1]
c=A[n//2]
for i in x:
    if i<=b:
        print(c)
    else:
        print(b)
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))
Y = [[X[k],k] for k in range(N)]
Z = Y.copy()
Z.sort()

A = [0 for k in range(N)]

for k in range(N):
    A[Z[k][1]] = (Z[:Y[k][1]]+Z[Y[k][1]+1:])[N//2-1][0]

for x in A:
    print(x)

# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
Y = [[X[k],k] for k in range(N)]
Y.sort()
A = [0 for k in range(N)]

for k in range(N):
    if k >= N//2:
        A[Y[k][1]] = Y[N//2-1][0]
    else:
        A[Y[k][1]] = Y[N//2][0]

for x in A:
    print(x)
# Original solution
from statistics import mean,median

n=int(eval(input()))
a=[int(i) for i in input().split()]

med=median(a)

a1=[i for i in a if i <= med]
a2=[i for i in a if i >= med]
#print(a1)
#print(a2)

for i in range(n):
  if a[i]<min(a2):
    print((min(a2)))
  else:
    print((max(a1)))

#if a[0] < median(a)
 

# Optimized solution
n=int(eval(input()))
a=[int(i) for i in input().split()]

b=sorted(a)

for i in range(n):
  if a[i]<=b[int(n/2)-1]:
    print((b[int(n/2)]))
  else:
    print((b[int(n/2)-1]))
# Original solution
n=int(eval(input()))
x=list(map(int,input().split()))


for i in range(n):
    xi = x[:i]+x[i+1:]
    xi.sort()
    print((xi[n//2-1]))


# Optimized solution
n=int(eval(input()))
x=list(map(int,input().split()))

sort_x = sorted(x)

for i in range(n):
    if x[i]<=sort_x[n//2-1]:
        print((sort_x[n//2]))
    else:
        print((sort_x[n//2-1]))
# Original solution
N=int(eval(input()))
X=list(map(int,input().split()))
for i in range(N):
    X_list=X[:i]+X[i+1:]
    X_list.sort()
    print((X_list[int(N/2-1)]))

# Optimized solution
N=int(eval(input()))
X=list(map(int,input().split()))
Y=X.copy()
Y.sort()
for i in range(N):
    if X[i]<Y[int(N/2)]:
        print((Y[int(N/2)]))
    else:
        print((Y[int(N/2)-1]))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=sorted(a)
l=b[:n//2]
u=b[n//2:]
for i in a:
  if i <= l[-1]:
    print((u[0]))
  else:
    print((l[-1]))

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=sorted(a)
c=b[n//2-1]
d=b[n//2]
if c==d:
  for i in range(n):print(c)
else:
  for i in range(n):
    if a[i]<=c:print(d)
    else:print(c)
# Original solution
N=int(eval(input()))
*X,=list(map(int,input().split()))


import statistics

for i in range(len(X)):
    t=X[:i]+X[i+1:]
    print((statistics.median(t)))

# Optimized solution
N=int(eval(input()))
*X,=list(map(int,input().split()))
s=sorted(X)

t1=s[N//2-1]
t2=s[N//2]

for x in X:
    if x<=t1:
        print(t2)
    else:
        print(t1)
# Original solution
import copy
import statistics
n = int(eval(input()))
x = list(map(int,input().split()))
l = ((len(x))//2)
for i in range(n):
	l2 = copy.copy(x)
	l2.pop(i)
	l2.sort()
	print((l2[l-1]))

# Optimized solution
import copy
n = int(eval(input()))
x = list(map(int,input().split()))
x2 = copy.copy(x)
x2.sort()
num1,num2 = (len(x)//2)-1,(len(x)//2)
med1,med2 = x2[num1],x2[num2]
for i in range(n):
	if x[i] <= med1:
		print(med2)
	else:
		print(med1)
# Original solution
#094
n=int(eval(input()))
x=list(map(int,input().split()))
x.insert(0,0) #x[0]に0を挿入
sorted_x = sorted(x[:])

for i in range(1,n+1):
    idx = sorted_x.index(x[i])
    print((sorted_x[n//2+1] if idx<=n//2 else sorted_x[n//2]))

# Optimized solution
n=int(eval(input()))
x=list(map(int,input().split()))
x.insert(0,0) #x[0]に0を挿入
sorted_x = sorted(x[:])

l,r=sorted_x[n//2],sorted_x[n//2+1]

for i in range(1,n+1):
    print((r if x[i]<=l else l))