N = int(eval(input()))

A = list(map(int, input().split()))



tmp = []

index = 0



for i in range(N):

  tmp.append([index, A[i]])

  if N % 2:

    if index <= 0:

      index = - index + 1

    else:

      index *= -1

  else:

    if index >= 0:

      index = - index - 1

    else:

      index *= -1



tmp.sort()

#print("tmp:", tmp)



answer = []

for i in range(N):

  answer.append(tmp[i][1])

print((*answer))
from collections import deque



N = int(eval(input()))

A = list(map(int, input().split()))



answer = deque([])

for i, a in enumerate(A):

  if i % 2 == 0:

    answer.appendleft(a)

  else:

    answer.append(a)

    

answer = list(answer)

answer = answer if N % 2 else answer[::-1]



print((*answer))
N = int(eval(input()))
A = list(map(int, input().split()))
tmp = []
index = 0
for i in range(N):
    tmp.append([index, A[i]])
    if N % 2:
        if index <= 0:
            index = -index + 1
        else:
            index *= -1
    else:
        if index >= 0:
            index = -index - 1
        else:
            index *= -1
tmp.sort()
# print("tmp:", tmp)
answer = []
for i in range(N):
    answer.append(tmp[i][1])
print((*answer))

from collections import deque

N = int(eval(input()))
A = list(map(int, input().split()))
answer = deque([])
for i, a in enumerate(A):
    if i % 2 == 0:
        answer.appendleft(a)
    else:
        answer.append(a)
answer = list(answer)
answer = answer if N % 2 else answer[::-1]
print((*answer))

+from collections import deque + -tmp = [] -index = 0 -for i in range(N): -    tmp.append([index, A[i]]) -    if N % 2: -        if index <= 0: -            index = -index + 1 -        else: -            index *= -1 +answer = deque([]) +for i, a in enumerate(A): +    if i % 2 == 0: +        answer.appendleft(a) -        if index >= 0: -            index = -index - 1 -        else: -            index *= -1 -tmp.sort() -# print("tmp:", tmp) -answer = [] -for i in range(N): -    answer.append(tmp[i][1]) +        answer.append(a) +answer = list(answer) +answer = answer if N % 2 else answer[::-1]