import java.util.*;
import java.io.*;

class salesman implements Runnable{
    public void run(){
       try{
           Scanner in = new Scanner(new File("salesman.in"));
           PrintWriter out = new PrintWriter(new File("salesman.out"));

           int n = in.nextInt();
           if(n!=1){

           int[] m = new int[n+1];
           int res = 0;

           for(int i = 0; i < n; i++){
               m[i]=in.nextInt();
               res+=2*m[i];
           }
           int mi=0, mj=1;
           int max = m[mi]+m[mj];

           for(int i = 0; i < n; i++){
               for(int j = i+1; j < n; j++){
                   int tmp = m[i]+m[j];
                   if(tmp > max){
                       max = tmp;
                       mi = i;
                       mj = j;
                   }
               }
           }
           res-=max;
           out.println(res);

           int k = 0, i = 0;
           out.print(mi+1 + " ");
           while(k < n-2){
               if(i!=mi && i!=mj){
                 out.print(i+1 + " ");
                 k++;
               }
               i++;
               if(i > n)
                 i-=n;
           }
           out.print(mj+1);
           }
           else {
              out.println(0);
              out.println(1);
           }

           in.close();
           out.close();
       }  catch(Exception e){
               e.printStackTrace();
               System.exit(1);
          }
     }
     public static void main(String[] args) {
       new Thread(new salesman()).start();
    }
}
