from sortedcontainers import SortedList N = int(input()) A = list(map(int,input().split())) INFTY = 10**14 Bl = [0]*N Br = [0]*N Cl = [0]*N Cr = [0]*N L = SortedList() L.add(A[0]) for i in range(N): if A[i]>L[0]: Bl[i] = L[0] else: Bl[i] = INFTY if L.bisect_right(A[i])R[0]: Br[i] = R[0] else: Br[i] = INFTY if R.bisect_right(A[i])=INFTY: print(-1) else: print(ans)