import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] maxes = new int[n + 3]; ArrayList[] lists = new ArrayList[n + 3]; for (int i = 0; i < 3; i++) { lists[i] = new ArrayList<>(); } String[] line = br.readLine().split(" ", n); for (int i = 3; i < n + 3; i++) { int x = Integer.parseInt(line[i - 3]); if (maxes[i - 2] <= maxes[i - 3]) { maxes[i] = maxes[i - 3] + x; lists[i] = (ArrayList)(lists[i - 3].clone()); lists[i].add(i - 2); } else { maxes[i] = maxes[i - 2] + x; lists[i] = (ArrayList)(lists[i - 2].clone()); lists[i].add(i - 2); } } int max = 0; ArrayList ans = null; for (int i = 0; i < 3; i++) { if (max < maxes[n + 2 - i]) { max = maxes[n + 2 - i]; ans = lists[n + 2 - i]; } } System.out.println(max); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ans.size(); i++) { if (i != 0) { sb.append(" "); } sb.append(ans.get(i)); } System.out.println(sb); } }