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

public class Main {
	static int opt = Integer.MAX_VALUE;
	static int cursum = 0;
	static int n;
	static boolean was[];
	static int way[];
	static int ans[];
	static int[][] matrix;

	public static void main(String args[]) throws Exception {
		Scanner s = new Scanner(new File("salesman.in"));
		PrintWriter out = new PrintWriter(new File("salesman.out"));
		n = s.nextInt();
		way = new int[n];
		ans = new int[n];
		int[] numbers = new int[n];

		for (int i = 0; i < n; i++) {
			numbers[i] = s.nextInt();
		}
		matrix = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				matrix[i][j] = numbers[i] + numbers[j];
			}
		}

		was = new boolean[n];
		Arrays.fill(was, false);
		was[0] = true;
		//printM();
		step(0);
		out.println(opt);
		int curr = 0;
		for(int i = 0; i < n; i++){
			out.print(curr+1+" ");
			curr  = ans[curr];
		}

		out.close();
	}

	static void printM() {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				System.out.print(matrix[i][j] + " ");
			}
			System.out.println();
		}
	}

	static void step(int row) {
		if (row == n - 1) {
			if (opt > cursum){
				opt = cursum;
				ans = Arrays.copyOf(way,n);
			}
				
			return;
		}
		for (int i = 0; i < n; i++) {
			if (was[i] == false && i != row) {
				was[i] = true;
				cursum += matrix[row][i];
				way[row] = i;
				step(row + 1);
				
				was[i] = false;
				cursum -= matrix[row][i];
			}
		}

	}
}
