Pagini recente » Cod sursa (job #2179518) | Cod sursa (job #1440632) | Cod sursa (job #2622068) | Cod sursa (job #2080210) | Cod sursa (job #1350505)
var n,m,i,j,r,k,t:longint;
a,b:array[0..150000] of longint;
begin
assign(input,'aib.in');
assign(output,'aib.out');
reset(input);
rewrite(output);
read(n,m);
for i:=1 to n do begin
read(a[i]);
b[i]:=b[i-1]+a[i];
end;
for i:=1 to m do begin
read(r);
if r<2 then begin
read(k,t);
if r=0 then
for j:=k to n do
b[j]:=b[j]+t;
if r=1 then writeln(b[t]-b[k-1]);
end else begin
read(k);
j:=1;
if r=2 then begin
while b[j]<k do
inc(j);
if b[j]=k then writeln(j)
else writeln(-1);
end;
end;
end;
end.