A toy factory produces traffic-light-themed tokens in three colors, represented as
Given a row of
You must accomplish this in a single pass over the row, using only constant extra space, without using a library sort function.
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).
Print the rearranged row as KaTeX can only parse string typed expression space-separated integers.
Input
6
2 0 2 1 1 0Output0 0 1 1 2 2Example 2:
Input
4
1 1 1 1Output1 1 1 1