import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;
class Main {
public static void main(String[] args) {
try (FileWriter fout = new FileWriter(new File("ssm.out"))) {
FastReader in = new FastReader(new FileReader(new File("ssm.in")));
int n = in.nextInt();
// int arr[] = new int[n];
// for (int i = 0; i < n; ++i) {
// arr[i] = in.nextInt();
// }
int num = in.nextInt();
int sumSoFar = num;
int minSoFar = num;
int minSoFarIdx = -1;
int maxSubsequence = num;
int maxSubEnd = 0;
int maxSubStart = 0;
for (int i = 1; i < n; ++i) {
num = in.nextInt();
sumSoFar += num;
if (sumSoFar < minSoFar) {
minSoFar = sumSoFar;
minSoFarIdx = i;
}
if (sumSoFar - minSoFar > maxSubsequence) {
maxSubsequence = sumSoFar - minSoFar;
maxSubEnd = i;
maxSubStart = minSoFarIdx + 1;
}
}
fout.write(maxSubsequence + " " +
(maxSubStart + 1) + " " + (maxSubEnd + 1));
} catch (IOException ex) {
ex.printStackTrace();
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
// public FastReader() {
// br = new BufferedReader(new InputStreamReader(System.in));
// }
public FastReader(FileReader in) {
br = new BufferedReader(in);
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}