""" 1,2の位置で構成する 2の桁以上で、最初に0になる桁が同じ数があれば終わり 実験 """ import sys import random N = int(input()) if N == 1: print (-1) sys.exit() A = list(map(int,input().split())) tup = None if N <= 1000: for i in range(N): for j in range(i+1,N): if (A[i]+1)^(A[j]+2) == (A[i]+2)^(A[j]+1): tup = (i,j) break else: import random for lp in range(10**6): i,j = random.randint(0,N-1),random.randint(0,N-1) if i == j: continue if (A[i]+1)^(A[j]+2) == (A[i]+2)^(A[j]+1): tup = (i,j) break if True: if tup == None: print (-1) sys.exit() else: P = [None] * N Q = [None] * N P[tup[0]] = Q[tup[1]] = 1 P[tup[1]] = Q[tup[0]] = 2 #print (P,Q) cnt = 3 for i in range(N): if P[i] == None: P[i] = Q[i] = cnt cnt += 1 print (*P) print (*Q)