#K1411. Move Zeros

    ID: 24062 Type: Default 1000ms 256MiB

Move Zeros

Move Zeros

You are given an array of integers. Your task is to move all the zeros in the array to the end while keeping the relative order of the non-zero elements unchanged.

Example: For an input array [0, 1, 0, 3, 12], the expected output is [1, 3, 12, 0, 0].

Note: The operation should be done in-place with a minimal number of operations.

inputFormat

The first line of input contains an integer n, representing the number of elements in the array. The second line contains n space-separated integers representing the elements of the array.

outputFormat

Output a single line with the modified array where all zeros are moved to the end. The elements should be separated by a single space.

## sample
5
0 1 0 3 12
1 3 12 0 0