#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
ll sum, sum_max;
int x, st, dr, n, st_max, dr_max, lg, lg_max;
int main()
{
fin >> n >> x;
sum = sum_max = x;
st = dr = st_max = dr_max = lg = lg_max = 1;
for(int i = 2; i <= n; ++i)
{
fin >> x;
if(sum + x > 0)
sum += x, lg++, dr++;
else
sum = x, lg = 1, st = i, dr = i;
if(sum > sum_max)
sum_max = sum, st_max = st, dr_max = dr, lg_max = lg;
else if(sum == sum_max)
if(st < st_max)
st_max = st, dr_max = dr, lg_max = lg;
else if(lg < lg_max)
dr_max = dr, lg_max = lg;
}
fout << sum_max << " " << st_max << " " << dr_max;
return 0;
}