#include <fstream>
using namespace std;
ifstream cin("ssm.in");
ofstream cout("ssm.out");
int suma[6000010];
int numere[6000001];
int numar;
int nr;
int maxx=-1e6;
int poz_max=-1e6;
void afisare(int poz,int s)
{
if(s>0)
{
s-=numere[poz];
afisare(poz-1,s);
}
else
cout<<poz+1<<' ';
}
int main()
{
cin>>numar;
for(int indice=1;indice<=numar;++indice)
{
cin>>numere[indice];
nr=numere[indice];
suma[indice]=max(suma[indice-1]+nr,nr);
if(maxx<suma[indice])
{
maxx=suma[indice];
poz_max=indice;
}
}
cout<<maxx<<' ';
afisare(poz_max,maxx);
cout<<' '<<poz_max;
return 0;
}