Color Sort Challenge

Medium

1s time · 256MB memory · arrays, two pointers

A conveyor belt carries crates painted in three colors, encoded 0, 1 and 2. The packing robot needs them grouped: all 0s first, then all 1s, then all 2s.

Sort the array and print it.

Input

The first line contains one integer n.

The second line contains n integers a₁ … aₙ, each of which is 0, 1 or 2.

Output

Print the sorted array as n space-separated integers.

Constraints

  • 1 ≤ n ≤ 2·10⁴
  • aᵢ ∈ {0, 1, 2}

Samples

Input 1
6
2 0 2 1 1 0
Output 1
0 0 1 1 2 2
Input 2
3
1 0 1
Output 2
0 1 1
Sign in (top right) to run or submit.