Problem:


Score : 300 points

Problem Statement

You are given an integer sequence of length n, a_1, ..., a_n.
Let us consider performing the following n operations on an empty sequence b.

The i-th operation is as follows:

Append a_i to the end of b.

Reverse the order of the elements in b.

Find the sequence b obtained after these n operations.

Constraints

1 \leq n \leq 2\times 10^5

0 \leq a_i \leq 10^9

n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print n integers in a line with spaces in between.
The i-th integer should be b_i.

Sample Input 1

4
1 2 3 4

Sample Output 1

4 2 1 3

After step 1 of the first operation, b becomes: 1.

After step 2 of the first operation, b becomes: 1.

After step 1 of the second operation, b becomes: 1, 2.

After step 2 of the second operation, b becomes: 2, 1.

After step 1 of the third operation, b becomes: 2, 1, 3.

After step 2 of the third operation, b becomes: 3, 1, 2.

After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.

After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.

Thus, the answer is 4 2 1 3.

Sample Input 2

3
1 2 3

Sample Output 2

3 1 2

As shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.

Sample Input 3

1
1000000000

Sample Output 3

1000000000

Sample Input 4

6
0 6 7 6 7 0

Sample Output 4

0 6 6 0 7 7



Sample input:
4
1 2 3 4


Sample output:
4 2 1 3

Submission status: Accepted

Solution code:
n = int(input())
out = [0 for x in range(n)]
inp = [int(x) for x in input().split(' ')]
if n%2==0:
    for i in range(n):
        if i % 2 == 0:
            out[int(n/2) + int(i/2)] = inp[i]
        else:
            out[int(n/2) - int((i+1)/2)] = inp[i]
else:
    k = int((n-1)/2)
    for i in range(n):
        if i % 2 == 0:
            out[k - int(i/2)] = inp[i]
        else:
            out[k+int((i+1)/2)] = inp[i]
for i in out:
    print(i, end=' ')

Submission status: Accepted

Solution code:
n = int(raw_input())
a = raw_input().split()

b = []
c = []
for i in range(n):
  if i % 2:
    b.append(a[i])
  else:
    # b.insert(0, a[i])
    c.append(a[i])

b = c[::-1] + b

if n % 2:
  print " ".join(b)
else:
  print " ".join(b[::-1])

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
B = []
if n%2:
	B = [A[n-1-2*i] for i in range(n//2)]
	B.append(A[0])
	B += [A[2*i+1] for i in range(n//2)]
else:
	B = [A[n-1-2*i] for i in range(n//2)]
	B += [A[2*i] for i in range(n//2)]
print(*B)

Submission status: Accepted

Solution code:
n = int(raw_input())
a = [int(_) for _ in raw_input().split()]

i = n - 1
while i >= 0:
    print a[i],
    i -= 2
if i == -1:
    i = 0
else:
    i = 1
while i < n - 2:
    print a[i],
    i += 2
if n != 1:
    print a[n - 2]

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

from collections import deque

q = deque()
for i in range(len(a)):
    if i & 1:
        q.appendleft(a[i])
    else:
        q.append(a[i])

q = list(q)
if len(q) & 1:
    q = reversed(q)

print(*q)

Submission status: Accepted

Solution code:
n=int(raw_input())
a=map(int,raw_input().split())
ansr=[]
ansl=[]
if n%2==0:
    for i in xrange(0, n, 2):
        ansr.append(a[i])
    for i in xrange(1, n, 2):
        ansl.append(a[i])
else:
    for i in xrange(0, n, 2):
        ansl.append(a[i])
    for i in xrange(1, n, 2):
        ansr.append(a[i])
ansl.reverse()
print " ".join(map(str,ansl)) +" "+ " ".join(map(str, ansr))

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[]
if N%2==0:
  for i in range(int(N/2)):
    b+=[a[N-1-2*i]]
  for i in range(int(N/2)):
    b+=[a[2*i]]
else:
  for i in range(int((N+1)/2)):
    b+=[a[N-1-2*i]]
  for i in range(int((N-1)/2)):
    b+=[a[2*i+1]]
print(' '.join(map(str, b)))

Submission status: Accepted

Solution code:
import collections

b = collections.deque()
n = int(input())
As = list(map(int, input().split()))
for i, a in enumerate(As):
    if i & 1:
        b.append(a)
    else:
        b.appendleft(a)
if n % 2 == 0:
    b.reverse()
print(*b)

Submission status: Accepted

Solution code:
# C
n = int(input())
a_list = list(input().split())

res_list = []
for i in range(n-1, -1, -2):
    res_list.append(a_list[i])
if n % 2 == 0:
    for i in range(0, n, 2):
        res_list.append(a_list[i])
else:
    for i in range(1, n, 2):
        res_list.append(a_list[i])
        
print(" ".join(res_list))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

B = []
ind = N - 1
for i in range(N - 1, -1, -2):
    B.append(A[i])

if N % 2 == 0:
    start = 0
else:
    start = 1

for i in range(start, N, 2):
    B.append(A[i])

print(" ".join(map(str, B)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(0, n, 2):
    b.append(a[i])
b = list(reversed(b))
for i in range(1, n, 2):
    b.append(a[i])
if n % 2 == 0:
    b = list(reversed(b))
print(' '.join(list(map(str, b))))

Submission status: Accepted

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))
b = collections.deque()

for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])
if n % 2 == 0:
    b.reverse()
print(*b)

Submission status: Accepted

Solution code:

import sys,collections
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n=int(input())

d=collections.deque()

c=0
for i in map(int,input().split()):
    if c==0:
        d.append(i)
        c=1
    else:
        d.appendleft(i)
        c=0

if c==1:
    l=list(d)[::-1]
else:
    l=list(d)

print(" ".join(map(str,l)))

Submission status: Accepted

Solution code:
from collections import deque


n = int(input())
a = list(map(int, input().split()))
b = deque()
for i in range(n):
    if i % 2:
        b.appendleft(a[i])
    else:
        b. append(a[i])
if n % 2:
    b.reverse()
print(' '.join(map(str, b)))

Submission status: Accepted

Solution code:
n = input()
xs = [int(c) for c in input().split()]

p = xs[::2]
q = xs[1::2]

if len(xs) & 1:
    a = list(reversed(p)) + q
else:
    a = list(reversed(q)) + p

print(' '.join(map(str, a)))

Submission status: Accepted

Solution code:
n = input()
A = raw_input().split()
B = A[0::2]
C = A[1::2]
if n % 2 == 1:
    print " ".join(B[::-1] + C)
else:
    print " ".join(C[::-1] + B)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int,input().split()))
check = N%2==0
for i,j in enumerate(a[1:]):
    if(check):
        if(i%2==0):
            ans.insert(0,j)
        else:
            ans.append(j)
    else:
        if(i%2==1):
            ans.insert(0,j)
        else:
            ans.append(j)
print(" ".join(map(str,ans)))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
b=list(b)
if n%2==0:
    print(*b)
else:
    print(*b[::-1])

Submission status: Runtime Error

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque([])
rev = 1
for i in a:
    if rev == 1:
        b.append(i)
        rev = -1
    elif rev == -1:
        b.appendleft(i)
        rev = 1

print(*(b if rev == 1 else b[::-1]))

Submission status: Runtime Error

Solution code:
import sys
n, *alst = map(int, sys.stdin.read().split())
lst1 = alst[::2]
lst2 = alst[1::2]
if n % 2:
  lst1.reverse()
  print(''.join(lst1 + lst2))
else:
  lst2.reverse()
  print(''.join(lst2 + lst1))

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
from collections import deque

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

q = deque()
q.append(A[0])
q.append(A[1])
for i in range(2, N):
  a = A[i]
  if i % 2 == 1:
    q.appendleft(a)
  else:
    q.append(a)

print(" ".join(map(str, q)))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))

b = []
for aa in a:
    b.append(aa)
    b.reverse()

ans = ''
for bb in b:
    ans += bb + ' '

print(ans[:-1])

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]

if (n % 2) == 0:
    print(*a[n-1::-2], *a[::2])
else:
    print(*a[n-1::-2], *a[1::2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]

if n % 2 == 0:
    print(*a[n-1::-2], *a[::2])
else:
    print(*a[n-1::-2], *a[1::2])

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = []

l1 = A[0::2]
l2 = A[1::2]
if N % 2 == 0:
    l2 = l2[::-1]
    ans = l2+l1
else:
    l1 = l1[::-1]
    ans = l1+l2

print(" ".join(ans))

Submission status: Runtime Error

Solution code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]


n = int(input())
a = ai()
MOD = 10**9+7

from collections import Counter
dup = list(Counter(sorted(a)).values()).index(2)+1
ant = a.index(dup)
post = a[::-1].index(dup)


def nCb(n, r):
    fac = [1, 1] + [0] * n
    finv = [1, 1] + [0] * n
    inv = [0, 1] + [0] * n
    for i in range(2, n + 2):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = -inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
        
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD


for k in range(1,n+2):
    if k == 1:
        print(n)
    else:
        ans = nCb(n+1,k)
        if ant+post+1 >= k:
            ans -= nCb(ant+post,k-1)
        print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b_1 = []
b_2 = []
b = []
for i in reversed(range(len(a))):
	if i % 2 != 0:
		b_1.append(a[i])
	else:
		b_2.append(a[i])
if len(a) % 2 == 0:
	b_2.reverse()
	b.extend(b_1)
	b.extend(b_2)
else:
	b_1.reverse()
	b.extend(b_2)
	b.extend(b_1)
for b_num in b:
	print("".join(b))

Submission status: Runtime Error

Solution code:
N = int(input())
a = input().split()
b = []
for i in range(len(a)):
	if i % 2 == 1:
		b.insert(0, a[i])
	else:
		b.append(a[i])
if N % 2 == 1:
	b = b.reverse()
print(b)
line = " ".join(b)
print(line)

Submission status: Runtime Error

Solution code:
import itertools
n,m,*a=map(int,open(0).read().split())
s=[0]*(2*m+2)
tot=0
for l,r in zip(a,a[1:]):
	tot+=(r-l)%m
	if l>r:
		r+=m
	dif=r-l
	if dif>1:
		s[l+2]+=1
		s[r+1]-=dif
		s[r+2]+=dif-1
s=list(itertools.accumulate(list(itertools.accumulate(s))))
print(tot-max(s[i]+s[m+i] for i in range(1,m)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n = int(input())
a = input().split()
l = []
r = []
for a_i in a:
    r += [ a_i ]
    l, r = r, l
print(*reversed(l), *r)

Submission status: Runtime Error

Solution code:
n = int(input())

a = map(int,raw_input().split())

b = []

for i in range(n):
    if i % 2 != n % 2:
        b.insert(0,a[i])
    else:
        b.append(a[i])

print(' '.join(map(str,b)))

Submission status: Runtime Error

Solution code:
n = int(input())

a = map(int,raw_input().split())

b = []

flag = True
for i in xrange(n):
    if flag:
        b.insert(0,a[i])
    else:
        b.append(a[i])

    flag = not flag

if n % 2 == 0:
    b.reverse()

print(' '.join(map(str,b)))

Submission status: Runtime Error

Solution code:
n = int(input())

a = map(int,raw_input().split())

b = []

for i in xrange(n):
    b.append(a[i])
    b.reverse()


print(' '.join(map(str,b)))

Submission status: Runtime Error

Solution code:
input_line_1 = raw_input()
input_line_2 = raw_input()
#N = int(input_line_1)
input_array = [int(i) for i in input_line_2.split(" ")]
M = int(input_line_1.split(" ")[1])
def count(base_val, input_array, M):
	return sum([min((input_array[i + 1] - input_array[i]) % M,
		 (input_array[i + 1] - base_val) % M + 1
		)
	 for i in range(len(input_array) - 1)])

#base_result = [(input_array[i + 1] - input_array[i]) % M for i in range(len(input_array) - 1)]
def count_2(base_val, input_array, M):
	return sum([min(base_result[i],(input_array[i + 1] - base_val) % M + 1)
	for i in range(len(input_array)-1)])

def count_3(base_val, input_array, M, base_result_i):
	diff_result = 0
	for index in range(len(input_array)-1):
		if ((input_array[index] < base_val) & (base_val < input_array[index + 1])):
			diff_result -= 1
			#print "p1", input_array[index], base_val,  input_array[index + 1]
		elif ((input_array[index] < base_val) & 
			  (base_val < (input_array[index + 1] + M)) & 
			  (input_array[index + 1] < input_array[index] < 0)
			  ):
			diff_result -= 1
			#print "p2", input_array[index], base_val,  input_array[index + 1]
		elif input_array[index + 1] == base_val:
			diff_result += (input_array[index + 1] - input_array[index] - 1) % M
			#print "p3", input_array[index], base_val,  input_array[index + 1]
	return base_result_i + diff_result

base_result = count(1, input_array, M)
best_result = base_result
for base_val in range(M + 1)[1:-1]:
	#print base_val,base_result,best_result 
	base_result = count_3(base_val, input_array, M, base_result)
	best_result = min(base_result,best_result) 


print best_result

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
occur = [0 for i in range(n + 1)]
MOD = 1000000007
for i in range(n + 1):
    if occur[a[i]] > 0: val = n - 1 - i + occur[a[i]]
    else: occur[a[i]] = i + 1
inv = [0 if i > 2 else 1 for i in range(n + 2)]
pinv = [0 if i > 2 else 1 for i in range(n + 2)]
perm = [0 if i > 2 else 1 for i in range(n + 2)]
for i in range(2, n + 2):
    inv[i] = -int(MOD / i) * inv[MOD % i] + MOD
    pinv[i] = pinv[i - 1] * inv[i] % MOD
    perm[i] = perm[i - 1] * i % MOD
def C(n, m):
    return (perm[m] * pinv[n] % MOD) * pinv[m - n] % MOD if n <= m else 0
for i in range(1, n + 2):
    temp = C(i, n + 1) - C(i - 1, val)
    if temp < 0: temp += MOD
    print(temp)

Submission status: Runtime Error

Solution code:
n=int(input());A=input().split();print(*A[-1::-2],*A[n%2::2])

Submission status: Runtime Error

Solution code:
import sys
from collections import deque

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [n, m] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = list(read_func().strip().split())
    min_cost = sys.maxint
    for i in range(m):
        x = i + 1
        cost = 0
        for j in range(n - 1):
            now = int(input_raw[j])
            target = int(input_raw[j + 1])
            if now < target:
                if x < target:
                    cost += min( (target - now),  1 +(target - x))
                elif x > target:
                    cost += min( (target - now), 1 + (m + target - x))
                else:
                    cost += 1
            elif now > target:
                if x < target:
                    cost += min((m + target - now),  1 +(target - x))
                elif x > target:
                    cost += min((m + target - now), 1 + (m + target - x))
                else:
                    cost += 1
        #print cost
        if cost < min_cost:
            min_cost = cost

    print min_cost


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
c=input().split()
for i in range(2):
    c[i]=int(c[i])
n=c[0]
m=c[1]
a=input().split()

for i in range(len(a)):
    a[i]=int(a[i])

b=[0 for i in range(m+1)]

for i in range(n-1):
    if(a[i]<a[i+1]):
        for j in range(a[i+1]-a[i]):
            b[a[i]+1+j]+=1
    else:
        for j in range(a[i+1]):
            b[j+1]+=1
        for j in range(m-a[i]):
            b[a[i]+1+j]+=1

max_value=0
max_num=0
for i in range(m):
    if(max_value<=b[i]):
        max_value=b[i]
        max_num=i

def move(x,y):
    result=0
    if(x<y):
        result=y-x
    else:
        result=(m-x)+y

    return result

sum_value=0
for i in range(n-1):
    sum_value+=min(move(max_num,a[i+1]),move(a[i],a[i+1]))
print(sum_value)

Submission status: Runtime Error

Solution code:
c=input().split
for i in range(2):
    c[i]=int(c[i])
n=c[0]
m=c[1]
a=input().split()

for i in range(len(a)):
    a[i]=int(a[i])

b=[0 for i in range(m+1)]

for i in range(n-1):
    if(a[i]<a[i+1]):
        for j in range(a[i+1]-a[i]):
            b[a[i]+1+j]+=1
    else:
        for j in range(a[i+1]):
            b[j+1]+=1
        for j in range(m-a[i]):
            b[a[i]+1+j]+=1

max_value=0
max_num=0
for i in range(m):
    if(max_value<=b[i]):
        max_value=b[i]
        max_num=i

def move(x,y):
    result=0
    if(x<y):
        result=y-x
    else:
        result=(m-x)+y

    return result

sum_value=0
for i in range(n-1):
    sum_value+=min(move(max_num,a[i+1]),move(a[i],a[i+1]))
print(sum_value)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

def comb(n, k):
    if k<0 or n<k:
        return 0

    if n-k<k:
        k=n-k
    return round(math.factorial(n)/math.factorial(k)/math.factorial(n-k))

n=int(input())
a=np.array([int(i) for i in input().split()])

count_lst=[[] for _ in range(n)]
for i in range(n+1):
    count_lst[a[i]-1].append(i)

for i in range(n):
    if len(count_lst[i])==2:
        left=count_lst[i][0]
        right=count_lst[i][1]
gapLen=right-left-1

del count_lst


base=10**9+7

for k in range(1, n+2):
    #print("k={}".format(k))
    retVal=0
    #retVal+=comb(n-1, k-2)#両方in
    #print(retVal)
    #retVal+=comb(n-1, k)#両方out
    #print(retVal)
    
    #retVal+=comb(n-1-gapLen, k-1)#片方in, gapから1つも選ばれない
    #print(retVal)    
    retVal+=2*(comb(n-1, k-1)-comb(n-1-gapLen, k-1))
    print(retVal%base)

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

def com(n, k):
    if n == 0 or k == 0:
        return 1
    return int(reduce(mul, range(n + 1 - k, n + 1)) / reduce(mul, range(1, k + 1)))

idx_list = [-1] * (n + 2)
l = 0
r = 0
for i, a_i in enumerate(a):
    if idx_list[a_i] < 0:
        idx_list[a_i] = i
    else:
        l = idx_list[a_i]
        r = n - i
        break

for k in range(1, n + 2):
    m = k - 1
    dup = 0
    for l_n in range(0, m + 1):
        r_n = m - l_n
        if l_n > l or r_n > r:
            continue
        l_c = com(l, l_n)
        r_c = com(r, r_n)
        dup += l_c * r_c
    ans = (com(n + 1, k) - dup) % (10 ** 9 + 7)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
N=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(N+1):
  if a[i] in c:
    b=a[i]
    j=c.index(a[i])
    k=i
    L=j+N-k
    break
  c+=[a[i]]
Base=N+1
Minu=1
for i in range(0,min(L+1,N+1)):
  print((Base-Minu)%(10**9+7))
  Base=int(Base*(N-i)/(i+2))
  Minu=int(Minu*(L-i)/(i+1))
  #print(int(math.factorial(N+1)/(math.factorial(i+1)*math.factorial(N-i))-math.factorial(L)/(math.factorial(i)*math.factorial(L-i))))
for i in range(L+1,N+1):
  print(Base%(10**9+7))
  Base=int(Base*(N-i)/(i+2))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[]

for i in range(n):

    if n-i*2-1 > 0:
        b.append(a[n-i*2-1])
    else:
        k=abs(n-i*2)
        b.append(a[k])


print(*b)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split(" ")))

a.insert(0,-1)

m=len(a)-1
res=""
k=m
if m%2==0:
    aa=0
else:
    aa=1

for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

k=s
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k+=2
    if k>=m:
        break

print(res)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split(" ")))

a.insert(0,-1)

m=len(a)-1
res=""
k=m
if m%2==0:
    aa=0
else:
    aa=1

for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

k=s
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k+=2
    if k>m:
        break

print(res)

Submission status: Runtime Error

Solution code:
from collections import Counter

n = int(input())
xs = [int(c) for c in input().split()]

mod = (10 ** 9) + 7

c = Counter(xs)

for k, v in c.items():
    if v == 2:
        dup = k

dup_idx = [i for i, v in enumerate(xs) if v == dup]

facts = [1]
for i in range(1, n + 3):
    facts.append(facts[-1] * i % mod)

def inv(x):
    return pow(x, mod - 2, mod)

def comb(p, q):
    if (not 0 <= q <= p) or p < 0:
        return 0
    return facts[p] * inv(facts[q]) % mod * inv(facts[p - q]) % mod

tl = n + 1
for l in range(1, n + 2):
    use_no = comb(tl - 2, l)
    use_both = comb(tl - 2, l - 2)
    use_one = comb(tl - 2, l - 1) * 2 - comb(min(dup_idx) + (tl - 1 - max(dup_idx)), l - 1)
    print((use_no + use_both + use_one) % mod)
    # print(use_no,use_both ,use_one)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))
b = collections.deque(list)
if n % 2 == 0:
    for i, ele in enumerate(a):
        if i % 2 == 0:
            b.append(ele)
        else:
            b.appendleft(ele)
else:
    for i, ele in enumerate(a):
        if i % 2 == 0:
            b.appendleft(ele)
        else:
            b.append(ele)

print(" ".join(b))