program raf105;
var
s,s2: string;
i,j,n,price,points: integer;
begin
write('Количество задач в карусели: ');
readln(n);
write('Ответы команды: ');
readln(s);
for i:=1 to length(s) do
if s[i]<>' '
then s2:= s2 + s[i];
price:= 3;
for i:=1 to length(s2) do
begin
if s2[i]='1'
then begin
points:= points + price;
price:= price + 1;
end
else for j:=1 to 3 do
if price > 3
then price:= price-1;
end;
writeln('Итоговый балл: ',points);
end.
<h3><u>PascalABC 3.4.2</u></h3>