import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } if (n == 1) { System.out.println(values[0]); System.out.println(1); return; } else if (n == 2) { if (values[0] < values[1]) { System.out.println(values[1]); System.out.println(2); } else { System.out.println(values[0]); System.out.println(1); } return; } int[] dp = new int[n]; int[] prev = new int[n]; dp[0] = values[0]; prev[0] = -1; dp[1] = values[1]; prev[1] = -1; dp[2] = values[0] + values[1]; prev[2] = 0; for (int i = 3; i < n; i++) { if (dp[i - 2] < dp[i - 3]) { dp[i] = dp[i - 3] + values[i]; prev[i] = i - 3; } else { dp[i] = dp[i - 2] + values[i]; prev[i] = i - 2; } } int idx; int ans; if (dp[n - 1] < dp[n - 2]) { idx = n - 2; ans = dp[n - 2]; } else { idx = n - 1; ans = dp[n - 1]; } ArrayDeque deq = new ArrayDeque<>(); while (idx >= 0) { deq.push(idx + 1); idx = prev[idx]; } StringBuilder sb = new StringBuilder(); boolean isFirst = true; while (deq.size() > 0) { if (!isFirst) { sb.append(" "); } isFirst = false; sb.append(deq.poll()); } System.out.println(ans); System.out.println(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }