uses crt;
const maxn=round(1e5);
type
tlist = array[1..maxn] of longint;
var n,i:longint;
a,b: tlist;
procedure qsortAB(var a,b : tlist);
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
while(i<=j) do
begin
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
y:=b[i]; b[i]:=b[j]; b[j]:=y;
inc(i);
j:=j-1;
end;
end;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
sort(1,n);
end;
begin
write('Nhap n: '); read(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,':'); read(a[i]);
end;
qsortAB(a,b);
clrscr;
writeln('Max la: ',a[n]);
for i:=1 to n do write(a[i],' ');
readln;
end.