LogiQuest

38. Move Zeroes

EasyArrayTwo Pointers

Move all zeros to the end of the array while keeping the relative order of the non-zero elements.

Input format

Line 1: n Line 2: n integers

Output format

The rearranged array, space-separated.

Example 1

Input

5
0 1 0 3 12

Output

1 3 12 0 0

Example 2

Input

1
0

Output

0

Constraints

1 ≤ n ≤ 10⁴

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…