program subq;
var
i,a,b,ma,mb,n:longint;
tmp:integer;
max,s:int64;
begin
assign (input,'subq.in');
reset (input);
readln (n);
a:=1;s:=0;b:=0;
max:=-maxint;ma:=0;mb:=0;
for i:=1 to n do begin
read (tmp);inc(b);
s:=s+tmp;
if s>max then begin
max:=s;
ma:=a;
mb:=b;
end;
if s<0 then begin
s:=0;
a:=i+1;
b:=i;
end;
end;
close (input);
assign (output,'subq.out');
rewrite (output);
writeln (ma);
writeln (mb);
writeln (max);
close (output);
end.