var
x,n,mix,i,j,m,b1,e1,b,e,l,l1,o,i1:longint;
begin
assign(input,'subq.in');
assign(output,'subq.out');
reset(input);
rewrite(output);
read(n);
read(x);
m:=x;
e1:=1;
b1:=1;
mix:=x;
e:=1;
b:=1;
for i:=2 to n do
begin
read(x);
if mix<x then begin mix:=x; e:=i;b:=i; end;
if x>o then begin o:=x; i1:=i; end;
if m>0 then begin m:=m+x; e1:=i; end
else begin m:=x; b1:=i; end;
if mix<m then begin mix:=m; b:=b1; e:=e1; end;
end;
writeln(b);
writeln(e);
writeln(mix);
close(input);
close(output);
end.