800. Move Zeroes

0

Easy

Given an array A, create a function that moves all occurrences of the number 0 to the end of the array while preserving the relative order of the non-zero elements.

Input Format

The first line of input contains an integer n, representing the size of the array. The next n lines contain a single integer each, representing the elements of the array.

Output Format

Print the resulting array.

Example

Input

5 0 1 0 3 12

Output

1 3 12 0 0

Constraints

Note: Perform this operation in-place without creating a duplicate array and aim to minimize the total number of operations.
Loading...

View Submissions

Console