var b,c,i,f,g,n,s,s1:integer;
a:array[1..1000000] of integer;
label 1,2;
begin
readln(n);
for i:=1 to n do
begin
read(a[i]);
end;
writeln;
i:=0;
1:i:=i+1;
if i=n then goto 2;
if a[i]>a[i+1] then
begin
b:=a[i];
a[i]:=a[i+1];
a[i+1]:=b;
i:=0;
goto 1;
end
else
begin
goto 1;
end;
2:s:=a[n]*a[n-1]*a[n-2];
s1:=a[1]*a[2]*a[3];
if s>s1 then
begin
write(a[n],' ');
write(a[n-1],' ');
write(a[n-2]);
end
else
begin
write(a[1],' ');
write(a[2],' ');
write(a[3],' ');
end;
end.
end.