Question
Festival Flag Sorting

A school is preparing flags for a cultural festival.

There are n flags placed in a row.

Each flag has one of three colors:

0 represents Red, 1 represents White, and 2 represents Blue.

The flags are currently mixed.

Your task is to rearrange the flags so that all Red flags come first, then all White flags, and then all Blue flags.

You must solve this using the Dutch National Flag algorithm.

Input

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

The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the colors of the flags.

Output

Print KaTeX can only parse string typed expression integers — the flags after sorting them in the order Red, White, and Blue.

Example
Example 1:
Input
8

2 0 1 2 1 0 0 2
Output
0 0 0 1 1 2 2 2
Explanation
The flags are rearranged so that all Red flags KaTeX can only parse string typed expression come first, followed by all White flags KaTeX can only parse string typed expression, and finally all Blue flags KaTeX can only parse string typed expression.

Online