#include <bits/stdc++.h>
using namespace std;
int n, a[26 << 1];
int v[26];
vector<int> x, y;
bitset<1200005> f[26 << 1][26];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= (n << 1); ++i) scanf("%d", &a[i]);
  sort(a + 1, a + (n << 1) + 1);
  reverse(a + 1, a + (n << 1) + 1);
  f[0][0][0] = 1;
  int sum = 0;
  for (int i = 1; i <= (n - 1) << 1; ++i) {
    f[i][0][0] = 1;
    sum += a[i];
    for (int j = 1; j <= i && j <= n - 1; ++j)
      f[i][j] = f[i - 1][j] | (f[i - 1][j - 1] << a[i]);
  }
  int state = (n - 1) << 1, rest = n - 1, half = sum >> 1;
  while (!f[state][n - 1][half]) --half;
  for (int i = (n - 1) << 1; i >= 1; --i)
    if (half >= a[i] && f[i - 1][rest - 1][half - a[i]] && rest) {
      x.push_back(a[i]);
      half -= a[i];
      --rest;
    } else
      y.push_back(a[i]);
  printf("%d ", a[(n << 1) - 1]);
  for (int i = 0; i < (int)x.size(); ++i) printf("%d ", x[i]);
  puts("");
  for (int i = (int)y.size() - 1; i >= 0; --i) printf("%d ", y[i]);
  printf("%d\n", a[n << 1]);
}
