cswork / OAOpen practice workspace

eBayOA #1

Zigzag Reorder

Estimated EasyJudge-ready

Topics (AI-labelled)Two PointersIn-place Arrays

Output the first element of the original array, then the last, then the second, then the second to last, alternately taking from both ends until all elements are used.

Input

n (original problem: 5≤n≤1000), followed by n integers (site supplement: −10⁹..10⁹).

Output

Output the n reordered numbers.

Example 1

Input:

7
1 6 9 4 3 7 8

Output:

1 8 6 7 9 3 4

Example 2

Input:

5
1 1 2 2 3

Output:

1 3 1 2 2

Example 3

Input:

5
9 -1 0 8 7

Output:

9 7 -1 8 0

Editorial

Loading solution…