var
max,n,m,i,x,y,l,r,zuo,you:longint;
s,a:Array[0..1000000]of longint;
begin
assign(input,'hill.in'); reset(input);
assign(output,'hill.out'); rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
s[i]:=s[i-1]+a[i];
end;
for i:=1 to m do
begin
readln(x,y);
max:=-maxlongint;
for l:=x to y do
for r:=l to y do
if s[r]-s[l-1]>max then
begin
max:=s[r]-s[l-1];
zuo:=l;
you:=r;
end;
writeln(zuo,' ',you,' ',max);
end;
close(input);
close(output);
end.