~/algor $ cat problems/massiv-nollarni-oxiriga
Zeros to the end
Easy
1000 ms
64 MB
31%
An array of $n$ integers is given. Move all zeros to the end of the array; the relative order of the non-zero elements must not change. Print the resulting array.
Input
The first line contains a positive integer $n$.
The second line contains $n$ integers — the elements of the array.
Output
$n$ integers separated by spaces.
Note
$1 \le n \le 1000$
the elements are from $-10^{6}$ to $10^{6}$
Examples
Input #1
7 0 3 0 -1 5 0 2
Output #1
3 -1 5 2 0 0 0
Input #2
3 0 0 0
Output #2
0 0 0