Question
The Ghost Tile March

After a parade, the ground crew must restore order to a row of n numbered tiles. Some tiles are blank (represented by 0). The crew must move all blank tiles to the end of the row while keeping the non-blank tiles in their original relative order at the front.

The operation must be done in-place with no extra array. The relative order of non-zero tiles must be preserved.

Input

The first line contains KaTeX can only parse string typed expression. The second line contains KaTeX can only parse string typed expression space-separated integers.

Output

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

Example
Example 1:
Input
5

0 1 0 3 12
Output
1 3 12 0 0

Example 2:
Input
3

0 0 0
Output
0 0 0

Online