Untitled

mail@pastecode.io avatar
unknown
pascal
2 years ago
634 B
7
Indexable
Never
uses crt;
var n,k,b,i,start,ans,j,s:longint;
    a:array[0..100] of longint;
begin
        clrscr;
        readln(n,k,b);
        for i:=1 to n do
        begin
                read(a[i]);
                s:=s+a[i];
        end;
        readln;
        //-----------------------
        if (b mod n<>0) then start:=b mod n
        else start:=n;

        for i:=1 to k div n do ans:=ans+s;

        j:=start;
        for i:=1 to k mod n do
        begin
                if (j=n+1) then j:=1;
                ans:=ans+a[j];
                inc(j);
        end;
        write(ans);
        readln
end.