Program gt;
label 1,2;
type ma=array[1..100000]of longint;
var A:ma;
p,l,g,n,i,j:longint;
begin
read(n);
for i:=1 to n do
begin
read(A[i]);
end;
for i:=1 to n-1 do
begin
for j:=1 to n-i do
begin
p:=A[j];
l:=A[j+1];
if A[j]>A[j+1] then beginA[j]:=l;A[j+1]:=p;
end;
end;
for g:=1 to n-1 do
begin
if(A[g]>a[g+1])then goto 2;
end;
goto 1;
2:
end;
1:
writeln(i);
for i:=1 to n do
begin
write(A[i],' ');
end;
end.
Если по убыванию то if(A[g]<a[g+1])then goto 2;