import java.io.*;
import java.util.*;

public class split_av_re {

	FastScanner in;
	PrintWriter out;
	final String fileName = "split".toLowerCase();

	void solve() {
		int n = in.nextInt();
		int[] a = new int[2 * n];
		for (int i = 0; i < 2 * n; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		Potion[] potions = new Potion[2 * n];
		for (int i = 0; i < 2 * n; i++) {
			potions[i] = new Potion(a[i]);
		}
		TreeSet<Difference> diffs = new TreeSet<>();
		for (int i = 0; i < 2 * n - 1; i++) {
			potions[i].next = potions[i + 1];
			potions[i + 1].prev = potions[i];
			diffs.add(new Difference(potions[i], potions[i + 1]));
		}

		List<Integer> ansBigger = new ArrayList<Integer>(), ansSmaller = new ArrayList<Integer>();

		for (int i = 0; i < n; i++) {
			Difference minDiff = diffs.pollFirst();
			ansBigger.add(minDiff.elem2.value);
			ansSmaller.add(minDiff.elem1.value);

			removeElements(minDiff.elem1, minDiff.elem2, diffs);
		}

		for (int i : ansBigger) {
			out.print(i + " ");
		}
		out.println();
		for (int j : ansSmaller) {
			out.print(j + " ");
		}
		out.println();
	}

	private void removeElements(Potion elem1, Potion elem2,
			TreeSet<Difference> diffs) {
		Potion prev = elem1.prev;
		Potion next = elem2.next;

		if (prev != null) {
			diffs.remove(new Difference(prev, elem1));
			prev.next = null;
		}
		if (next != null) {
			diffs.remove(new Difference(elem2, next));
			next.prev = null;
		}
		
		if (prev != null && next != null) {
			diffs.add(new Difference(prev, next));
			prev.next = next;
			next.prev = prev;
		}
	}

	class Potion {
		int value;
		Potion next, prev;

		public Potion(int value) {
			super();
			this.value = value;
		}
	}

	class Difference implements Comparable<Difference> {
		Potion elem1, elem2;

		public Difference(Potion elem1, Potion elem2) {
			this.elem1 = elem1;
			this.elem2 = elem2;
		}

		@Override
		public int compareTo(Difference o) {
			if (elem2.value - elem1.value == o.elem2.value - o.elem1.value) {
				return o.elem2.value - elem2.value;
			}
			return (elem2.value - elem1.value)
					- (o.elem2.value - o.elem1.value);
		}
	}

	void run() {
		try {
			in = new FastScanner(fileName + ".in");
			out = new PrintWriter(fileName + ".out");
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new split_av_re().run();
	}
}
