A school is preparing flags for a cultural festival.
There are
Each flag has one of three colors:
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.
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.
Print KaTeX can only parse string typed expression integers — the flags after sorting them in the order Red, White, and Blue.
Input
8
2 0 1 2 1 0 0 2Output0 0 0 1 1 2 2 2ExplanationThe 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.