Var a,i,j,b,p,p1:longint;
m:array[0..501] of longint;
procedure qsort(l,r:longint);
var q,w,i,j,p:longint;
begin
q:=m[(l+r) div 2];
repeat
while m[i]while m[j]>q do dec(j);
if ibegin
w:=m[i];
m[i]:=m[j];
m[j]:=w;
inc(i); dec(j);inc(p);
end;
if i=j then
begin
inc(i);dec(j);
end;
until i>j;
if iif jp1:=p;
end;
begin
for i:=1 to 500 do
m[i]:=random(100);
for i:=1 to 500 do
for j:=500 downto i+1 do
if m[j]begin
a:=m[j];
m[j]:=m[i];
m[i]:=a;
inc(p);
end;
writeln(p);
qsort(1,500);
writeln(p1);
end.