import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.io.File;
import java.io.PrintWriter;

/**
 * Created by IntelliJ IDEA.
 * User: m09fpv
 * Date: 02.12.2009
 * Time: 17:53:02
 * To change this template use File | Settings | File Templates.
 */
public class salesman {
 public static void main(String[]  args) throws Exception {
   Scanner in=new  Scanner(new File("salesman.in"));
   PrintWriter out=new PrintWriter(new File("salesman.out"));
   int n=in.nextInt(); int t,tmp,cnt,tmp2;
   boolean x=true;
   if(n==1){ x=false; }
   int[] a=new int[n];
   int[] b=new int[n];
   for(int i=0;i<n;i++){
     t=in.nextInt();
     a[i]=t;
     b[i]=i;
   }
   for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
     if(a[j]>a[j+1]){
       tmp2=a[j]; a[j]=a[j+1]; a[j+1]=tmp2;
       tmp2=b[j]; b[j]=b[j+1]; b[j+1]=tmp2;
     }
    }
   }
   cnt=a[n-1]+a[0];
   for(int i=0;i<n-2;i++){
    tmp=a[i]+a[i+1];
    cnt=cnt+tmp;
   }
   if(x){ out.println(cnt); }
   else { out.println("0"); }
   out.print(b[n-1]+1+" ");
   for(int i=0;i<n-1;i++){
    out.print(b[i]+1+" ");
   }
   in.close();
   out.close();
  }
}
