#C13276. Custom Odd-Even Sort

    ID: 42796 Type: Default 1000ms 256MiB

Custom Odd-Even Sort

Custom Odd-Even Sort

Given a list of integers, rearrange the list so that all the odd numbers appear first in ascending order, followed by all the even numbers in descending order.

More precisely, let \(O\) be the set of odd numbers in the list and \(E\) be the set of even numbers. We need to output the sequence:

\[ sorted(O) \; \Vert \; sorted(E) \text{ (in descending order)} \]

For example, given the list: 5 3 2 8 1 4, the desired rearrangement is: 1 3 5 8 4 2.

inputFormat

The first line of input contains an integer n — the number of elements in the list. The second line contains n space-separated integers.

outputFormat

Output the rearranged list in one line, with the numbers separated by a single space. There should be no extra spaces at the end of the line.

## sample
6
5 3 2 8 1 4
1 3 5 8 4 2

</p>