#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
int n, m, sum;
int a[55];
bitset<1250005> f[55][30];
bool vis[55];
void dfs(int x, int y, int z) {
  if (x == 2 || y == 0) return;
  if (f[x - 1][y][z])
    dfs(x - 1, y, z);
  else
    vis[x] = 1, dfs(x - 1, y - 1, z - a[x]);
}
void out(int x) {
  dfs(m, n - 1, x);
  cout << a[1];
  for (register int i = (3); i <= (m); ++i)
    if (vis[i]) cout << ' ' << a[i];
  puts("");
  for (register int i = (m); i >= (3); --i)
    if (!vis[i]) cout << a[i] << ' ';
  cout << a[2];
  exit(0);
}
signed main() {
  n = read(), m = n * 2;
  for (register int i = (1); i <= (n * 2); ++i) a[i] = read(), sum += a[i];
  sort(a + 1, a + n * 2 + 1);
  sum = (sum - a[1] - a[2]) / 2;
  f[2][0][0] = 1;
  for (register int i = (3); i <= (m); ++i) {
    for (register int j = (min(i - 2, n - 1)); j >= (1); --j)
      f[i][j] |= (f[i - 1][j]) | (f[i - 1][j - 1] << a[i]);
    f[i][0].set(0);
  }
  for (register int i = (sum); i >= (0); --i)
    if (f[m][n - 1][i]) out(i);
  return 0;
}
