Question
Sorting the Traffic Light Tokens

A toy factory produces traffic-light-themed tokens in three colors, represented as 0 for red, 1 for yellow, and 2 for green.

Given a row of n tokens in mixed order, rearrange them in-place so that all red tokens come first, followed by all yellow tokens, followed by all green tokens.

You must accomplish this in a single pass over the row, using only constant extra space, without using a library sort function.

Input

The first line contains a single integer KaTeX can only parse string typed expression — the number of tokens.

The second line contains KaTeX can only parse string typed expression integers, each either KaTeX can only parse string typed expression, KaTeX can only parse string typed expression, or KaTeX can only parse string typed expression (this line may be empty if KaTeX can only parse string typed expression).

Output

Print the rearranged row as KaTeX can only parse string typed expression space-separated integers.

Example
Example 1:
Input
6

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


Example 2:
Input
4

1 1 1 1
Output
1 1 1 1

Online