#include <stdio.h>
int main(){
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
int N, S, Smax, x, i, start, start2, end, negStartEnd, max = -999999;
bool allNegatives = true;
scanf("%d ", &N);
S = Smax = 0;
start = start2 = 1;
for(i=1; i<=N; i++){
scanf("%d ", &x);
S += x;
if(S < 0){
S = 0;
start2 = i + 1;
if(x > max){
max = x;
negStartEnd = i;
}
} else {
allNegatives = false;
if(S > Smax){
Smax = S;
end = i;
start = start2;
}
}
}
if(allNegatives == true)
printf("%d %d %d",max, negStartEnd,negStartEnd);
else
printf("%d %d %d",Smax, start,end);
return 0;
}