- ← Back
- P1 (1)
- P1 (2)
- P2 (1)
- P2 (2)
- P3 (1)
- P3 (2)
- P3 (3)
- P3 (4)
- P4 (1)
- P4 (2)
- P4 (3)
- P4 (4)
- P4 (5)
- P4 (6)
- P4 (7)
- P4 (8)
- P5 (1)
- P5 (2)
- P5 (3)
- P5 (4)
- P6 (1)
- P6 (2)
- P6 (3)
- P6 (4)
- Гурток 1A
- Гурток 1B
- Гурток 1С
- Гурток 1D
- Гурток 1E
- Гурток 1F
- Гурток 2A
- Гурток 2B
- Гурток 2C
- Гурток 2D
- Гурток 2Е
- Гурток 2F
Odd Array
Limits: 2 sec., 256 MiB
Zenyk and Marichka have an array of \(n\) integers \(a_i\). They want to rearrange the elements of the array so that the sum of any two consecutive elements is odd.
Please, help them to do so or determine that it is impossible.
Input
The first line contains one integer \(n\). The second line contains \(n\) integers \(a_i\).
Output
Output one line with \(n\) integers
— the rearranged elements of the array so that the sum of any two
consecutive elements is odd, or -1 if it is impossible.
Constraints
\(1 \le n \le 10^5\),
\(1 \le a_i \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 4 7 47 | 7 4 47 |
| Input (stdin) | Output (stdout) |
|---|---|
| 4 4 44 444 4444 | -1 |
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|