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: ok = 0 p1 = [0]*(n) p2 = [0]*(n) s = set([i for i in range(1, n+1)]) mx = max(a) sa = set(a) pos = [-1]*(mx+1) for i in range(n): pos[a[i]] = i for xi in range(n): x = a[xi] for yi in range(i+1, n): y = a[yi] d = y-x if y + d > mx:break if 1 + 2 * d > n:break if y+d in sa: zi = pos[y+2*d] p1[xi], p1[yi], p1[zi] = 1+d, 1+d+d, 1 p2[xi], p2[yi], p2[zi] = 1+d+d, 1, 1+d ok = 1 s.discard(1) s.discard(1+d) s.discard(1+d+d) break if ok: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)