var
x:array[1..100] of integer;
i,n:integer;
begin
read(n);
writeln;
for i:=1 to n do
read(x[i]);
writeln;
for i:=1 to n do
if x[i]>0 then write(x[i],' ');
for i:=1 to n do
if x[i]<0 then write(x[i],' ');
for i:=1 to n do
if x[i]=0 then write(x[i],' ');
end.