#include <iostream>
#include <fstream>
using namespace std;
int a[100002],sum[100002],best[100002];
int main()
{
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n,poz=0,k,maxx=-2000000000,minn=2000000000,poz1,poz2;
fin>>n;
for(int i=1; i<=n; i++)
{
fin>>a[i];
}
sum[0] = 0;
for (int i = 1; i <= n; i++)
sum[i] = a[i] + sum[i-1];
minn = sum[0];
for (int i = 1; i <= n; i++)
{
best[i] = sum[i] - minn;
if (minn > sum[i]){
minn = sum[i];
poz1=i+1;
}
if (maxx < best[i]){
maxx = best[i];
poz2=i;
}
}
fout<<maxx<<" "<<poz1<<" "<<poz2;
return 0;
}