import java.net.NetworkInterface; import java.util.*; import javax.swing.event.AncestorEvent; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] susi = new int[n+1]; for(int i=1;i<=n;i++) susi[i]=sc.nextInt(); int[] dp = new int[n+1]; dp[1]=susi[1]; int max = dp[1]; for(int i=2;i<=n;i++){ dp[i]=Math.max(dp[i-1], dp[i-2]+susi[i]); max=Math.max(max, dp[i]); } ArrayList get = new ArrayList<>(); int index = n; while(index>0){ if(dp[index]==dp[index-1]){ index--; }else{ get.add(index); index-=2; } } String aaa = ""; Collections.reverse(get); for(int a:get) aaa+=a+" "; System.out.println(max); System.out.println(aaa.trim()); } }