import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] list = new int[n]; for(int i = 0; i < n; i++) { list[i] = sc.nextInt(); } if(n == 1) { System.out.println(list[0]); System.out.println(1); return; } int[] dp = new int[n]; int[] pre = new int[n]; dp[0] = list[0]; pre[0] = -1; dp[1] = list[1]; pre[1] = -1; for(int i = 2; i < n; i++) { if(i >= 3) { int a = dp[i-2] + list[i]; int b = dp[i-3] + list[i]; if(a < b) { dp[i] = b; pre[i] = i-3; } if(a >= b) { dp[i] = a; pre[i] = i-2; } } else { dp[i] = dp[i-2] + list[i]; pre[i] = i-2; } } ArrayList plist = new ArrayList(); if(dp[n-1] >= dp[n-2]) { int prenumber = n-1; while(prenumber != -1) { plist.add(prenumber); prenumber = pre[prenumber]; } } else { int prenumber = n-2; while(prenumber != -1) { plist.add(prenumber); prenumber = pre[prenumber]; } } System.out.println(Math.max(dp[n-1], dp[n-2])); System.out.print((plist.get(plist.size()-1) + 1)); for(int i = plist.size()-2; i >= 0; i--) { System.out.print(" " + (plist.get(i) + 1)); } System.out.println(); } }