Financial literacy
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
Marichka has just made a new bank card for herself and is already planning to make a lot of purchases. However, she is worried that the bank will consider her transactions suspicious and block her card.
Zenyk, in strict confidence (nobody knows where he himself learned about this), told Marichka how the transaction suspicion checking system works. It turns out that after each purchase, the bank calculates the total amount of money spent and checks whether this sum is odd. If the sum is odd — everything is fine, she can continue using the card. If the sum is even — the bank considers the last transaction suspicious and blocks the card.
Marichka is planning \(n\) purchases with costs \(a_1, a_2, \dots, a_n\) in any order. Help her determine the order in which to make the purchases so that her card is not blocked. Or tell that this is impossible to do.
Input
The first line contains a single integer \(n\) — the number of purchases Marichka plans to make.
The second line contains \(n\) natural numbers \(a_i\) — the cost of the \(i\)-th purchase.
Output
In the first line, print NO if it is impossible to make
the purchases such that the total amount of spent money after each of
them is odd, or YES if it is possible.
If the answer is YES, then in the second line print
\(n\) numbers: the costs of the
purchases in the order they should be made.
Constraints
\(1 \le n \le 10^5\),
\(1 \le a_i \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 2 4 7 | YES 7 4 |
| Input (stdin) | Output (stdout) |
|---|---|
| 7 4 77 47 44 74 7 4 | NO |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|