import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n = int(input()) a = list(map(int,input().split())) if len(set(a)) != n: x = [[] for i in range(max(a)+10)] for i in range(n): x[a[i]].append(i) ok = 1 p1 = list(range(1, n+1)) p2 = list(range(1, n+1)) for i in range(max(a)+10): if len(x[i]) >= 2: s,t = x[i][0], x[i][1] p2[t], p2[s] = p2[s], p2[t] break else: a = [[a[i], i] for i in range(n)] a.sort() ok = 0 p1 = [0]*(n) p2 = [0]*(n) s = set([i for i in range(1, n+1)]) for i in range(2, n): x,xi = a[i-2] y,yi = a[i-1] z,zi = a[i] d1 = y-x d2 = z-y if z-x < n and d1 == d2: p1[xi], p1[yi], p1[zi] = 1+d1, 1+d1+d2, 1 p2[xi], p2[yi], p2[zi] = 1+d1+d2, 1, 1+d1 ok = 1 s.discard(1) s.discard(1+d1) s.discard(1+d1+d2) break s = list(s) for i in range(n): if p1[i]: continue num = s.pop() p1[i] = num p2[i] = num if ok: print(*p1) print(*p2) else: print(-1)