1 #include<iostream>
2 using namespace std;
3 int main()
4 {
5 int i;
6 while(scanf("%d",&i)!=EOF)
7 {
8 int j,k,m,n,temp,begin_new,begin,end,max=-100000,sum=0;
9 bool judge=true;
10 if(i==0) break;
11 for(j=1;j<=i;j++)
12 {
13 scanf("%d",&k);
14 if(k>=0) judge=false;
15 sum+=k;
16 if(k>sum)
17 {
18 begin_new=k;
19 sum=k;
20 }
21 if(sum>max)
22 {
23 begin=begin_new;
24 max=sum;
25 end=k;
26 if(j==1){begin=k;begin_new=k;}
27 begin=begin_new;
28 }
29 }
30 if(judge)printf("%c %d %d\n",'0',begin,k);
31 else printf("%d %d %d\n",max,begin,end);
32 }
33 }
34