var f,g:text;
min,smin,n,m,i,j,z,x,y,v1,v2:longint;
h:array[1..5000] of longint;
s:array[1..5000,1..2] of longint;
begin
assign(f,'cuburi2.in'); reset(f);
assign(g,'cuburi2.out'); rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
read(f,h[i]); s[i,1]:=0; s[i,2]:=0;
end;
{failed}
for i:=1 to m do
begin
read(f,x,y);
min:=0; smin:=maxlongint;
for z:=x to y do
for j:=x to z-1 do
begin
s[z,1]:=s[z,1]+h[j]*(z-j);
s[j,2]:=s[j,2]+h[z]*(z-j);
end;
for z:=x to y do
begin
if s[z,1]+s[z,2]<smin then begin min:=z; smin:=s[z,1]+s[z,2]; end;
end;
writeln(g,min,' ',smin);
for z:=1 to n do begin s[z,1]:=0; s[z,2]:=0; end;
end;
close(f); close(g);
end.