#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
int n;
int v[55];
int dp[27][26 * 50001];
int val[27][26 * 50001];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n + n; i++) cin >> v[i];
  sort(v, v + n + n);
  for (int i = 0; i < 27; i++)
    for (int j = 0; j < 26 * 50001; j++) dp[i][j] = 1e9;
  dp[1][v[0]] = 1e7;
  val[1][v[0]] = v[0];
  for (int i = 1; i < n + n; i++) {
    for (int c = min(i + 1, n); c >= 1; --c) {
      for (int k = n * 50000; k >= 0; --k) {
        if (c == i) {
          if (k >= v[i]) {
            if (dp[c - 1][k - v[i]] < dp[c][k]) {
              dp[c][k] = dp[c - 1][k - v[i]];
              val[c][k] = v[i];
            }
          }
          if (dp[c][k] < 1e9) dp[c][k] = v[i];
        } else {
          if (c == i + 1) {
            if (k >= v[i]) {
              dp[c][k] = dp[c - 1][k - v[i]];
              val[c][k] = v[i];
            }
            continue;
          }
          if (k >= v[i] && dp[c - 1][k - v[i]] < dp[c][k]) {
            dp[c][k] = dp[c - 1][k - v[i]];
            val[c][k] = v[i];
          }
        }
      }
    }
  }
  int ans = INT_MAX;
  int sum = accumulate(v, v + n + n, 0), take;
  for (int i = 0; i < n * 50000 + 1; i++) {
    if (max(i + dp[n][i], v[0] + (sum - i)) < ans) {
      ans = max(i + dp[n][i], v[0] + (sum - i));
      take = i;
    }
  }
  vector<int> up;
  int cnt = n;
  while (cnt) {
    up.push_back(val[cnt][take]);
    take -= up.back();
    cnt--;
  }
  sort(up.begin(), up.end());
  vector<int> down;
  for (int i = 0, j = 0; i < n + n; i++) {
    if (j != up.size() && up[j] == v[i])
      j++;
    else
      down.push_back(v[i]);
  }
  reverse(down.begin(), down.end());
  for (auto x : up) cout << x << ' ';
  cout << '\n';
  for (auto x : down) cout << x << ' ';
  cout << '\n';
  return 0;
}
