#include <bits/stdc++.h>
using namespace std;
const int maxn = 6000000;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n, a[maxn], dp[maxn], maxim, start, x, y;
int main()
{
fin >> n;
for (int i = 1; i <= n; i++)
fin >> a[i];
dp[1] = a[1];
maxim = a[1];
start = 1;
x = y = 1;
for (int i = 2; i <= n; i++)
{
if (dp[i - 1] + a[i] < a[i])
{
dp[i] = a[i];
start = i;
}
else
{
dp[i] = dp[i - 1] + a[i];
if (dp[i] > maxim)
{
maxim = dp[i];
x = start;
y = i;
}
}
}
fout << maxim << " " << x << " " << y;
return 0;
}