#include <iostream>
#include <fstream>
using namespace std;
const char iname[] = "ssm.in";
const char oname[] = "ssm.out";
int main() {
ifstream in(iname);
int n, S, S_max, first = 1, last = 1, nr, min_first = 0;
in >> n;
in >> S;
S_max = S;
for (int i = 2; i <= n; i++) {
in >> nr;
if (S + nr >= nr) {
S += nr;
} else {
S = nr;
if (first < last) {
min_first = first;
}
first = i;
}
if (S > S_max) {
S_max = S;
last = i;
}
}
ofstream out(oname);
if (min_first == 0) {
out << S_max << " " << first << " " << last;
} else {
out << S_max << " " << min_first << " " << last;
}
in.close();
out.close();
return 0;
}