import java.io.*; import java.lang.*; import java.util.*; class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(in.readLine()); int[] B = new int[N], C = new int[N]; TreeMap map = new TreeMap<>(); Item item = new Item(1, N, 0); map.put(item.key, item); String[] nums = in.readLine().split(" "); for (int i = 0; i < N; i++) { int a = Integer.parseInt(nums[i]); item = map.remove(new Key(a, a)); B[i] = item.depth; C[i] = item.key.ub - item.key.lb; for (Item tmp : item.split(a)) { map.put(tmp.key, tmp); } } for (int i = 0; i < N; i++) { if (i > 0) System.out.print(" "); System.out.print(B[i]); } System.out.println(); for (int i = 0; i < N; i++) { if (i > 0) System.out.print(" "); System.out.print(C[i]); } System.out.println(); } } class Key implements Comparable { int lb, ub; Key(int lb, int ub) { this.lb = lb; this.ub = ub; } public int compareTo(Key o) { if (this.ub < o.lb) { return -1; } else if (o.ub < this.lb) { return 1; } else { return 0; } } } class Item { Key key; int depth; Item(int lb, int ub, int depth) { this.key = new Key(lb, ub); this.depth = depth; } Item[] split(int a) { if (key.lb == a && key.ub == a) { return new Item[0]; } else if (key.lb == a) { return new Item[] { new Item(a+1, key.ub, depth+1) }; } else if (key.ub == a) { return new Item[] { new Item(key.lb, a-1, depth+1) }; } else { return new Item[] { new Item(key.lb, a-1, depth+1), new Item(a+1, key.ub, depth+1) }; } } }