N=int(input()) A=[int(input()) for i in range(N)] ANS=[-1]*N QS=[set(range(N)) for i in range(N)] for i in range(N): if A[i]