#C8333. Wave Form Arrangement

    ID: 52304 Type: Default 1000ms 256MiB

Wave Form Arrangement

Wave Form Arrangement

Given a list of integers, arrange them into a wave form such that the list follows the pattern: \(a_0 \ge a_1 \le a_2 \ge a_3 \le \ldots\). In other words, every even-indexed element (0-indexed) should be greater than or equal to its adjacent odd-indexed neighbors, and every odd-indexed element should be less than or equal to its adjacent even-indexed neighbors.

Your task is to output one valid wave form arrangement. Note that multiple valid answers may exist.

inputFormat

The first line of input contains an integer \(n\), representing the number of elements in the list. The second line contains \(n\) space-separated integers.

outputFormat

Output the rearranged list of integers in wave form in a single line, with each element separated by a space.

## sample
6
3 6 5 10 7 20
6 3 10 5 20 7