#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("ssm.in");
ofstream fout ("ssm.out");
int n;
long long a[6000041];
int main()
{
fin >> n;
long long sumax = 0;
int indi, indj;
sumax = indi = indj = 0;
long long sumcurent;
int ic, jc;
ic = jc = 0;
sumcurent = 0;
for(int i = 0; i < n; i++)
{
long long x;
fin >> x;
if(sumcurent == 0)
{
ic = i;
}
sumcurent += x;
if(sumcurent > 0)
{
jc = i;
}
if(sumcurent < 0)
{
sumcurent = 0;
}
if(sumcurent > sumax)
{
sumax = sumcurent;
indi = ic;
indj = jc;
}
}
fout << sumax << " " << indi+1 << " " << indj+1;
return 0;
}