#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int N_MAX = 24;
const int A_MAX = 50005;
int N;
vector<int> A;
long long possible[N_MAX + 1][N_MAX * A_MAX];
int main() {
  cin >> N;
  A.resize(2 * N);
  for (int &a : A) cin >> a;
  sort(A.begin(), A.end());
  int first_min = A.front();
  A.erase(A.begin());
  int second_min = A.front();
  A.erase(A.begin());
  N--;
  memset(possible, -1, sizeof(possible));
  possible[0][0] = 0;
  for (int i = 0; i < 2 * N; i++)
    for (int k = min(i, N - 1); k >= 0; k--)
      for (int s = 0; s <= k * A_MAX; s++)
        if (possible[k][s] >= 0)
          possible[k + 1][s + A[i]] = possible[k][s] | 1LL << i;
  int total_sum = accumulate(A.begin(), A.end(), 0);
  long long best_mask = -1;
  for (int s = total_sum / 2; s >= 0; s--)
    if (possible[N][s] >= 0) {
      best_mask = possible[N][s];
      break;
    }
  vector<int> rows[2];
  rows[0] = {first_min};
  rows[1] = {second_min};
  for (int i = 0; i < 2 * N; i++)
    if (best_mask >> i & 1)
      rows[0].push_back(A[i]);
    else
      rows[1].push_back(A[i]);
  reverse(rows[1].begin(), rows[1].end());
  for (int r = 0; r < 2; r++)
    for (int i = 0; i <= N; i++) cout << rows[r][i] << (i < N ? ' ' : '\n');
}
