3 a
:array [0..10000] of longint;
7 for i
:=1 to n
do read(a
[i
]);
11 while (j
>0) and (a
[j
]>a
[j
+1]) do dec(j
);
14 for j
:=1 to n
do a
[j
]:=j
;
17 for l
:=n
downto j
+1 do
18 if (a
[l
]>a
[j
]) then break
;
19 a
[0]:=a
[j
]; a
[j
]:=a
[l
]; a
[l
]:=a
[0];
20 for l
:=j
+1 to (n
+j
+1) div 2 do
22 a
[0]:=a
[l
]; a
[l
]:=a
[n
-l
+j
+1]; a
[n
-l
+j
+1]:=a
[0];
26 for i
:=2 to n
do write(' ',a
[i
]);