uses crt;
var a:array[1..100]of integer;
i,n,k,x,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n-1 do
for k:=i+1 to n do
if a[i]<a[k] then
begin
t:=a[i];
a[i]:=a[k];
a[k]:=t;
end;
writeln('Day giam dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
write('Nhap so nguyen x:'); readln(x);
i:=1;
while (x<a[i]) and (i<=n) do
inc(i);
for k:=n+1 downto i do
a[k]:=a[k-1];
a[i]:=x;
writeln('Day so duoc sap xep giam dan sau khi chen ',x,' la: ');
for i:=1 to n+1 do
write(a[i]:4);
readln;
end.