*Tăng dần:
uses crt;
var i,n:longint;
a:array[0..1000000] of longint;
procedure sort(l,r:longint);
var i,j,x,temp:longint;
begin
i:=l;j:=r;x:=a[(l+r) div 2];
repeat
while a[i] < x do inc(i);
while x < a[j] do dec(j);
if i<=j then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
inc(i);dec(j);
end;
until i>j;
if l < j then sort(l,j);
if i < r then sort(i,r);
end;
begin
clrscr;
readln(n);
for i:=1 to n do read(a[i]);
sort(1,n);
for i:=1 to n do write(a[i],' ');
readln;readln;
end.
============================
*Giảm dần:
uses crt;
var i,n:longint;
a:array[0..1000000] of longint;
procedure sort(l,r:longint);
var i,j,x,temp:longint;
begin
i:=l;j:=r;x:=a[(l+r) div 2];
repeat
while a[i] > x do inc(i);
while x > a[j] do dec(j);
if i<=j then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
inc(i);dec(j);
end;
until i>j;
if l < j then sort(l,j);
if i < r then sort(i,r);
end;
begin
clrscr;
readln(n);
for i:=1 to n do read(a[i]);
sort(1,n);
for i:=1 to n do write(a[i],' ');
readln;readln;
end.