import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] dp = new int[n + 3]; ArrayList> lists = new ArrayList<>(); for (int i = 0; i < n + 3; i++) { lists.add(new ArrayList<>()); } for (int i = 3; i < n + 3; i++) { int x = sc.nextInt(); if (dp[i - 3] < dp[i - 2]) { lists.get(i).addAll(lists.get(i - 2)); dp[i] = dp[i - 2] + x; } else { lists.get(i).addAll(lists.get(i - 3)); dp[i] = dp[i - 3] + x; } lists.get(i).add(i - 2); } int ans; ArrayList ansList; if (dp[n + 2] > dp[n + 1]) { ans = dp[n + 2]; ansList = lists.get(n + 2); } else { ans = dp[n + 1]; ansList = lists.get(n + 1); } System.out.println(ans); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ansList.size(); i++) { if (i > 0) { sb.append(" "); } sb.append(ansList.get(i)); } System.out.println(sb); } }