Grouping even and odd indices of a list

Kotlin Medium lists

Task «Grouping even and odd indices of a list»

Write a program that takes a list of integers, splits it into two sublists: elements with even indices (0, 2, 4...) and with odd indices (1, 3, 5...), then returns a new list where first come all elements of even indices in reverse order, followed by all elements of odd indices in their original order. If the original list is empty, output an empty list.

Input Format

The first line contains an integer N (0 ≤ N ≤ 1000) — the number of elements. The second line contains N integers separated by spaces.

Output Format

One line with numbers separated by spaces — the result of the transformation.

Examples

Example 1

INPUT
5 1 2 3 4 5
OUTPUT
5 3 1 2 4

Example 2

INPUT
4 10 20 30 40
OUTPUT
30 10 20 40

Example 3

INPUT
abcabcabc
OUTPUT
3

Example 4

INPUT
0
OUTPUT

Example 5

INPUT
aaaa
OUTPUT
2
main.kt