n = int(input()) A = list(map(int, input().split())) L = [] R = [] A = [(a, i) for i, a in enumerate(A, 1)] A.sort(reverse = True) t = 0 for _, i in A: if t: L.append(i) else: R.append(i) t ^= 1 ans = L[::-1] + R ind = ans.index(1) ans = ans[ind:] + ans[:ind] + [1] print(*ans)