Given a sequence of $n$ integers $a_1, a_2, \dots, a_n$, rearrange the sequence such that all elements at odd indices (1-based indexing) are output first, followed by all elements at even indices.
Input
The first line contains an integer $n \ (1 ≤ n ≤ 100)$, the length of the sequence.
The second line contains $n$ integers $a_1, a_2, \dots, a_n \ (1 \le a_i \le 10^9)$, the sequence.
Output
Output the sequence with all odd-indexed elements (1-based) first, followed by all even-indexed elements, separated by spaces.
Sample Test Cases
Input | Output | |
---|---|---|
7 1 2 3 4 5 6 7 |
1 3 5 7 2 4 6 | |
6 60 50 40 30 20 10 |
60 40 20 50 30 10 |
Scoring: Per Subtask
Authored by hclee and s17f18
Appeared in 2025 Mini Comp 1