Var
A, A1 :array [1..100] of real;
max, preValue, pre :real;
i, n :integer;
begin
read(n);
max := A1[1];
for i := 1 to n do begin
read(A[i]);
if (A[i] > 0) then A1[i] = A[i];
if (A1[i] > max) then max := A1[i];
end;
preValue := A[1];
A[1] := max;
for i := 1 to n do begin
pre := A[i];
A[i] := preValue;
preValue := pre;
end;
for i := 1 to n do
write(A[i], ' ');
writeln();
for i := 1 to n do
write(A1[i], ' ');
end.