#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int a[6000004],best[6000004],bestSum, n;
void Citire()
{
fin >> n;
for(int i = 1; i <= n; i++)
fin >> a[i];
}
void Rezolvare()
{
int pozi = 1,pozf = 1,ok = 0;
bestSum = a[1];
for (int i = 1; i <= n; ++ i) {
best[i] = a[i];
if (best[i] < best[i-1] + a[i]){
best[i] = best[i-1] + a[i];
}
else pozi = i;
if (bestSum < best[i]){
bestSum = best[i];
pozf = i;
}
}
fout << bestSum << " " << pozi << " " << pozf;
}
int main()
{
Citire();
Rezolvare();
return 0;
}