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

#define mp make_pair

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());
	set<pair<pair<int, int>, int> > s;
	set<pair<int, pair<int, int> > > id;
	for (int i = 1; i < 2 * n; i++)
	{
		pair<int, int> p = mp(a[i] - a[i - 1], -a[i]);
		s.insert(mp(p, i)), id.insert(mp(i, p));
	}	
	id.insert(mp(-1, mp(0, 0)));
	id.insert(mp(1e9, mp(0, 0)));
	for (int i = 0; i < n; i++)
	{
		pair<pair<int, int>, int> cur = *s.begin();
		s.erase(s.begin());
		pair<int, int> p = cur.first;
		int uk = cur.second;
		id.erase(mp(uk, p));
		b.push_back(-p.second), c.push_back(-p.second - p.first);
		if (s.empty()) break;
		set<pair<int, pair<int, int> > >::iterator iter = id.lower_bound(mp(uk, p));
		iter--;
		pair<int, pair<int, int> > p1 = (*(iter));
		if ((*id.upper_bound(mp(uk, p))).first == 1e9)
		{
			id.erase(p1);
			s.erase(mp(p1.second, p1.first));
			continue;
		}
		pair<int, pair<int, int> > p2 = *(id.upper_bound(mp(uk, p)));
		if (iter == id.begin())
		{
			id.erase(p2);
			s.erase(mp(p2.second, p2.first));
			continue;
		}	
		id.erase(p1), id.erase(p2); 
		s.erase(mp(p1.second, p1.first));
		s.erase(mp(p2.second, p2.first));
		p = mp(-p2.second.second + p1.second.first + p1.second.second, p2.second.second);
		id.insert(mp(uk, p));
		s.insert(mp(p, uk));
	}
	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" : " ");	
}
