Var
a, b: array[1..110000] of integer;
i, n, j, cnt, min: integer;
fl: boolean;
begin
Readln(n);
for i := 1 to n do
Read(a[i]);
min:= a[1];
j:= 1;
for i := 2 to n do
if a[i] < min then
begin
min:= a[i];
j:= i;
end;
fl := true;
for i:= 1 to j do
write(a[i], ' ');
for i:= j + 1 to n do
begin
if a[i] > 0 then fl := false;
if (a[i] < 0)and(fl) then continue;
write(a[i], ' ');
end;
end.