#include <fstream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	ifstream cin("split.in");
	ofstream cout("split.out");
	int n;
	cin >> n;
	vector<int> a(2 * n), b, c;
	for (int i = 0; i < 2 * n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++)
	{
		int p1 = -1, dif = 1e9 + 1;
		
		for (size_t j = 1; j < a.size(); j++)
			if ((a[j] - a[j - 1]) <= dif)
			{
				p1 = j - 1;
				dif = a[j] - a[j - 1];
			}
		b.push_back(a[p1 + 1]), c.push_back(a[p1]);
		a.erase(a.begin() + p1), a.erase(a.begin() + p1);
	}	
	for (int i = 0; i < n; i++)
		cout << b[i] << ((i + 1 == n) ? "\n" : " ");
	
	for (int i = 0; i < n; i++)
		cout << c[i] << ((i + 1 == n) ? "\n" : " ");	
}

