#include<stdio.h>
#include<stdlib.h> int main()
{
int k;
int *data;
int i;
int ThisSum, MaxSum, FirstNum, LastNum, tempFir, tempLas; while(scanf("%d", &k) != EOF)
{
data = (int *)malloc(k * sizeof(int));
for(i = ; i < k; i++)
{
scanf("%d", &data[i]);
} ThisSum = ;
MaxSum = ;
FirstNum = ;
LastNum = k - ;
tempFir = ;
tempLas = ; for(i = ; i < k; i++)
{
if(ThisSum >= )
{
ThisSum += data[i];
tempLas = i;
}
else
{
ThisSum = data[i];
tempFir = i;
tempLas = i;
}
if(ThisSum > MaxSum || ((LastNum == k - )&&(ThisSum == )))
{
MaxSum = ThisSum;
FirstNum = tempFir;
LastNum = tempLas;
}
}
printf("%d %d %d", MaxSum, data[FirstNum], data[LastNum]);
}
}