from collections import deque n=int(input()) ls=list(map(int,input().split())) DQ=deque() for i in range(n): DQ.append(i) while len(DQ)>2: for i in range(len(DQ)//2): m=DQ.pop();n=DQ.pop() if ls[m]>=ls[n]: DQ.appendleft(m) print(DQ.pop()+1)