///subsecenta de suma maxima
#include <iostream>
#include <fstream>
#include <vector>
#include <limits>
using namespace std;
int main() {
ifstream inStr("ssm.in");
ofstream outStr("ssm.out");
int N;
inStr >> N;
vector<int> a(N);
for(int i=0; i<N; ++i)
inStr >> a[i];
int start = 0, end, best = 0,
max = numeric_limits<int>::min(), bs, be;
for(int i=0; i<N; ++i) {
if(best + a[i] > a[i]) {
best += a[i];
end = i;
}
else {
best = a[i];
start = end = i;
}
if(best > max) {
max = best;
bs = start;
be = end;
}
}
outStr << max << ' ' << bs + 1 << ' ' << be + 1 << '\n';
return 0;
}