#C1947. Rearrange Array in Specific Order

    ID: 45208 Type: Default 1000ms 256MiB

Rearrange Array in Specific Order

Rearrange Array in Specific Order

You are given an even integer \(n\) and an array of \(n\) integers. Your task is to rearrange the array in a specific order defined by the formula: \(a_1, a_n, a_2, a_{n-1}, \dots\). In other words, move the first element, then the last element, followed by the second element, then the second-to-last element, and so on. This process guarantees that all elements are paired in the order required.

Note: It is guaranteed that \(n\) is even (i.e. \(2 \leq n \leq 10^5\)).

inputFormat

The input consists of two lines:

  • The first line contains an even integer (n), the number of elements in the array.
  • The second line contains (n) space-separated integers representing the array elements.

outputFormat

Output a single line containing the rearranged array as a sequence of space-separated integers.## sample

6
1 2 3 4 5 6
1 6 2 5 3 4