uses crt;
var a:array[1..100]of integer;
i,n,k,x,tam,vt: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
tam:=a[i];
a[i]:=a[k];
a[k]:=tam;
end;
write('Nhap gia tri 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('Mang da chen x la: ');
for i:=1 to n+1 do
write(a[i]:4);
writeln;
for i:=1 to n+1 do
if a[i]=x then vt:=i;
writeln('Vi tri da chen la: ',vt);
readln;
end.