N = int(input()) A = [] for i in range(N): A.append(int(input())) dp = [set() for i in range(N)] for i, x in enumerate(A): for j in range(N): if j != x: dp[i].add(j) ans = -float('inf') import random for i in range(400000): st = set() temp = 0 l = [] for d in dp: d -= st while True: if len(d) == 0: break item = random.sample(d, 1) if not item[0] in st: st.add(item[0]) l.append(item[0]) temp += 1 break if temp == N: break if len(l) < N: print(-1) exit() for d in l: print(d)