#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;
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;
first = i;
}
if (S > S_max) {
S_max = S;
last = i;
}
}
if (first > last) {
first = last;
}
ofstream out(oname);
out << S_max << " " << first << " " << last;
in.close();
out.close();
return 0;
}