import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static class MyScanner implements Closeable {
BufferedReader br;
StringTokenizer st;
public MyScanner(String file) throws FileNotFoundException {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file)), 1 << 16);
}
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;
}
@Override
public void close() throws IOException {
br.close();
}
}
public static void main(String[] args) throws IOException {
//long startTime = System.currentTimeMillis();
try (MyScanner scanner = new MyScanner("ssm.in");
// BufferedReader reader = new BufferedReader(new FileReader("ssm.in"));
BufferedWriter writer = new BufferedWriter(new FileWriter("ssm.out"), 1024)) {
int N = scanner.nextInt();
// int[] a = new int[N+1];
//StringTokenizer st = new StringTokenizer(reader.readLine());
// for (int i = 1; i <= N; i++) {
// a[i] = scanner.nextInt();
// }
// st = null;
// a[1] = scanner.nextInt();
int sum = scanner.nextInt();
int maxSum = sum;
int first = 1;
int start = 1;
int end = 1;
for (int i = 2; i <= N; i++) {
int val = scanner.nextInt();
if (sum >= 0) {
sum += val;
} else {
sum = val;
first = i;
}
if (sum > maxSum) {
maxSum = sum;
start = first;
end = i;
}
}
writer.write(maxSum + " " + start + " " + end);
//System.out.println(System.currentTimeMillis() - startTime);
}
}
}