#include<bits/stdc++.h>
using namespace std;
#define s a
int n,a[1000001]={0};
//int kkk[1000001];
int Main(){
freopen("subq.in","r",stdin);
freopen("subq.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
a[i]+=a[i-1];}
int miku=-1e9,lty,rty;
int head=1,tail=0;
int t=1e9,p=0;
for(int i=0;i<n;i++){
if(t>s[i]){
t=s[i];
p=i;
}
if(miku<a[i+1]-t){
miku=a[i+1]-t;
rty=i+1;
lty=p+1;
}
}
cout<<lty<<endl<<rty<<endl<<miku;
return 0;
}
int lie=Main();
int main(){
}