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]; C[0] = N - 1; TreeMap map = new TreeMap<>(); String[] nums = in.readLine().split(" "); for (int i = 0; i < N; i++) { int a = Integer.parseInt(nums[i]); Integer lb = map.lowerKey(a); Integer ub = map.higherKey(a); if (lb == null) { if (ub != null) { B[i] = B[map.get(ub)] + 1; C[i] = (ub - 1) - 1; } } else if (ub == null) { B[i] = B[map.get(lb)] + 1; C[i] = N - (lb + 1); } else { B[i] = Math.max(B[map.get(lb)], B[map.get(ub)]) + 1; C[i] = (ub - 1) - (lb + 1); } map.put(a, i); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream out = new PrintStream(baos); for (int i = 0; i < N; i++) { if (i > 0) out.print(" "); out.print(B[i]); } out.println(); for (int i = 0; i < N; i++) { if (i > 0) out.print(" "); out.print(C[i]); } out.println(); System.out.write(baos.toByteArray()); } }