import java.io.File;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) throws Exception {
		Scanner s = new Scanner(new File("salesman.in"));
		PrintWriter out = new PrintWriter(new File("salesman.out"));
		int n = s.nextInt();
		int sum = 0;
		int max1 = Integer.MIN_VALUE;
		int ind1 = 0;
		int max2 = Integer.MIN_VALUE;
		int ind2 = 0;
		for(int i = 0; i < n; i++){
			int a = s.nextInt();
			if(a > max1){
				
				max2 = max1;
				ind2 = ind1;
				
				max1 = a;
				ind1 = i+1;
			}
			else{
				if( a > max2){
					max2 = a;
					ind2 = i+1;
				}
			}
			sum+=a*2;
		}
		if(n == 1){
			out.println(0);
			out.println(1);
		}
		else{
			if(n == 2){
				out.println(sum/2);
				out.println(1+" "+ 2);
			}
			else{
				out.println(sum - max1 - max2);
				out.print(ind1+ " ");
				for(int i = 1; i <= n; i++){
					if(i!= ind1 && i!= ind2){
						out.print(i+" ");
					}
				}
				out.println(ind2);
			}
		}
		
		out.close();
	}

	}
