Ethan and Justin are arguing over how to sort a list of $$$n$$$ distinct integers. Ethan wants ascending order; Justin wants descending order. Unable to agree, they settle on a compromise: arrange the numbers in a zigzag pattern, so that the sequence alternately rises and falls.
A sequence $$$a_1, a_2, \ldots, a_n$$$ is zigzag if odd-indexed elements are local peaks (each is greater than its immediate neighbors) and even-indexed elements are local valleys (each is less than its immediate neighbors).
Given the list, output any re-ordering of the given integers so that the final sequence forms a zigzag sequence.
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of integers.
The second line contains $$$n$$$ distinct integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10000$$$) — the list.
Print $$$n$$$ integers on a single line — any permutation of the input that forms a zigzag sequence. It is guaranteed that a solution always exists.
There are multiple possible correct answers — any correct answer will be accepted.
51 2 3 4 5
5 3 4 1 2
42 7 1 8
8 1 7 2