program sapxep;
var
i, j, n, x: integer;
a: array[1..100] of integer;
begin
write('Nhap so phan tu trong day: ');
readln(n);
for i := 1 to n do
begin
write('a[', i, ']= ');
readln(a[i]);
end;
for i := 1 to n - 1 do
for j := i + 1 to n do
if a[i] > a[j] then
begin
x := a[i];
a[i] := a[j];
a[j] := x;
end;
write('Nhap so x: ');
readln(x);
for i := 1 to n do
begin
if x <= a[i] then
begin
for j := n downto i + 1 do
a[j] := a[j-1];
a[i] := x;
break;
end;
end;
writeln('Day so vua sap xep va them phan tu x:');
for i := 1 to n do
write(a[i], ' ');
writeln;
end.