#include <bits/stdc++.h>
int n, a[60], f[27][1250010], sum, vis[60], st[30];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n * 2; i++) scanf("%d", a + i), sum += a[i];
  std::sort(a + 1, a + 2 * n + 1);
  sum -= a[1] + a[2];
  memset(f, 0xff, sizeof(f));
  f[0][0] = 0;
  for (int i = 3; i <= 2 * n; i++)
    for (int j = std::min(i - 3, n - 2); ~j; j--)
      for (int k = 0; k <= sum / 2 - a[i]; k++)
        if (f[j][k] != -1 && f[j + 1][k + a[i]] == -1) f[j + 1][k + a[i]] = i;
  int x = 0, y = 0;
  for (int i = sum / 2; ~i; i--)
    if (f[n - 1][i] != -1) {
      x = f[n - 1][i], y = i;
      break;
    }
  for (int i = n - 1; i; i--, y -= a[x], x = f[i][y]) {
    vis[x] = 1, st[i] = a[x];
  }
  printf("%d ", a[1]);
  std::sort(st + 1, st + n);
  for (int i = 1; i < n; i++) printf("%d ", st[i]);
  puts("");
  for (int i = 3, j = 0; i <= 2 * n; i++)
    if (!vis[i]) st[++j] = a[i];
  std::sort(st + 1, st + n);
  for (int i = n - 1; i; i--) printf("%d ", st[i]);
  printf("%d\n", a[2]);
  return 0;
}
