Question
The Tricolour Signal Untangle

A smart traffic system uses three signal states: 0 (red — stop), 1 (yellow — caution), and 2 (green — go). A log of n signal readings has arrived in a random order. The system needs to sort the log in-place so all red signals come first, then yellow, then green — using only a single pass and O(1) extra memory.

Input

The first line contains KaTeX can only parse string typed expression. The second line contains KaTeX can only parse string typed expression space-separated integers, each KaTeX can only parse string typed expression, KaTeX can only parse string typed expression, or KaTeX can only parse string typed expression.

Output

KaTeX can only parse string typed expression space-separated integers — the sorted sequence.

Example
Example 1:
Input
6

2 0 2 1 1 0
Output
0 0 1 1 2 2

Example 2:
Input
3

0 0 0
Output
0 0 0

Online