Var
a : array [1..100] of integer;
n, i, c, free : integer;
begin
read (n);
for i := 1 to n do read (a[i]);
c := 0;
for i := 1 to n do
if a[i] = 0 then c := c + 1;
free := n;
for i := n downto 1
do
if a[i] <> 0 then
begin
a[free] := a[i];
free := free - 1;
end;
for i := 1 to c do
a[i] := 0;
for i := 1 to n do
write (a[i], ' ');
end.