#K43182. Taco Bin Arrangement

    ID: 27253 Type: Default 1000ms 256MiB

Taco Bin Arrangement

Taco Bin Arrangement

You are given a list of distinct positive integers representing bin IDs. Your task is to determine whether it is possible to rearrange these bin IDs in such a way that for every consecutive pair \(a_i\) and \(a_{i+1}\) in the sequence, either \(a_{i+1} = 2 \times a_i\) or \(a_{i+1} = \frac{a_i}{2}\) holds.

If such an arrangement exists, output YES along with one valid arrangement. Otherwise, output NO.

Note: If multiple valid arrangements exist, you only need to output one of them.

inputFormat

The input is given from standard input (stdin) and consists of two lines:

  • The first line contains a single integer \(n\), which is the number of bin IDs.
  • The second line contains \(n\) space-separated integers representing the bin IDs.

outputFormat

If a valid arrangement exists, print YES on the first line and a valid arrangement (\(n\) space-separated integers) on the second line. Otherwise, print NO on a single line.

## sample
4
4 1 8 2
YES

1 2 4 8

</p>