Const n = 15;
var a: array[1..n] of integer;
i, j, m: integer;
begin
// генерация и вывод
randomize;
for i := 1 to n do a[i] := Random(19)-8;
for i := 1 to n do write(a[i], ' ');
writeln;
// Сортировка
for i := 1 to n-1 do begin
m := i;
for j := i+1 to n do
if a[j] < a[m] then m := j;
if m <> i then begin
j := a[m];
a[m] := a[i];
a[i] := j;
end;
end;
for i := 1 to n do write(a[i], ' ');
writeln;
// поиск наибольшей разности
m := a[2] - a[1];
for i := 3 to n do
if a[i] - a[i-1] > m then
m := a[i] - a[i-1];
writeln ('разность = ', m);
end.