#C11168. Wave Array Transformation

    ID: 40454 Type: Default 1000ms 256MiB

Wave Array Transformation

Wave Array Transformation

Given an array of integers, your task is to rearrange the array into a wave-like pattern. In other words, after rearrangement, the array should satisfy the condition:

\(a_0 \ge a_1 \le a_2 \ge a_3 \le \dots \)

You can achieve this by first sorting the array in non-decreasing order and then swapping every adjacent pair of elements. Note that multiple answers may be acceptable as long as the wave condition holds.

inputFormat

The first line contains a single integer n representing the number of elements in the array.

The second line contains n space-separated integers.

outputFormat

Output a single line containing the rearranged array elements in their wave-like order, separated by a single space.

## sample
5
1 3 4 2 5
2 1 4 3 5