{$APPTYPE CONSOLE}
{$R+,S+,Q+,T+,O-}
uses SysUtils,Math;
var n,i,ts,res,tmp:integer;
    mas,gp,nd,next,prev:array[-1..400003]of integer;
    dif:array[-1..499999]of integer;
    tree:array[1..870000]of integer;
procedure qsort(l,r:integer);
var i,j,x,t:integer;
begin
  i:=l;
  j:=r;
  x:=mas[random(j-i + 1) + i];
  while i<=j do
    begin
      while (mas[i]<x)do inc(i);
      while (mas[j]>x)do dec(j);
      if i<=j then
        begin
          t:=mas[i];
          mas[i]:=mas[j];
          mas[j]:=t;
          inc(i);
          dec(j);
        end;
    end;
  if i<=r then qsort(i,r);
  if l<=j then qsort(l,j);
end;

procedure up(a,x:integer);
var i:integer;
begin
  tree[ts + a - 1]:= x;
  i:=ts+a-1;
  while (i div 2>=1)do begin
    if tree[2* (i div 2) + 1] = 0 then
      tree[i div 2]:= tree[2 * (i div 2)]else
    if dif[tree[2* (i div 2)]] < dif[tree[2* (i div 2) + 1]] then
      tree[i div 2]:=tree[2* (i div 2)]
    else tree[i div 2]:=tree[2* (i div 2) + 1];
    i:=i div 2;
    end;
end;

function treeSize(n:integer):integer;
var i:integer;
begin
  for i:=1 to max(n, 10) do
    if trunc(power(2,i)) >= n then
      begin
        result:=trunc(power(2,i));
        exit;
      end;
end;

begin
  reset(input,'split.in');
  rewrite(output,'split.out');
  read(n);
  n:=2*n;
  for i:=1 to n do
    read(mas[i]);
  qsort(1,n);
  ts:=treeSize(n-1);
  for i:=1 to ts do
    dif[i]:=maxlongint;
  for i:=1 to n - 1 do
    begin
      dif[i]:=mas[i + 1]-mas[i];
      next[i]:=i + 1;
      prev[i + 1]:=i;
    end;
  for i:=1 to ts do
    tree[ts + i - 1]:=i;
  for i:=1 to ts do
    up(i, i);
  res:=0;  
  while (dif[tree[1]]<>maxlongint)do
    begin
      inc(res);
      gp[res]:=mas[tree[1]];
      nd[res]:=mas[next[tree[1]]];
      dif[tree[1]]:=maxlongint;
      tmp:=tree[1];
      up(tree[1],tree[1]);
      dif[next[tmp]]:=maxlongint;
      if (next[tmp] <= ts) then
        up(next[tmp], next[tmp]);
      next[prev[tmp]]:=next[next[tmp]];
      prev[next[next[tmp]]]:=prev[tmp];
      if (prev[tmp] >= 1)then
      if not((next[prev[tmp]] = 0)or(mas[next[prev[tmp]]] = maxlongint))then
        dif[prev[tmp]]:=mas[next[prev[tmp]]]-mas[prev[tmp]]
      else dif[prev[tmp]]:=maxlongint;
      if (prev[tmp] >= 1) then
        up(prev[tmp], prev[tmp]);
    end;
  for i:=1 to res do write(nd[i], ' ');
  writeln;
  for i:=1 to res do write(gp[i], ' ');
end.
