Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed n cans in a row on a table. Cans are numbered from left to right from 1 to n. Vasya has to knock down each can exactly once to finish the exercise. He is allowed to choose the order in which he will knock the cans down.

Vasya knows that the durability of the i-th can is a_i. It means that if Vasya has already knocked x cans down and is now about to start shooting the i-th one, he will need (a_i ⋅ x + 1) shots to knock it down. You can assume that if Vasya starts shooting the i-th can, he will be shooting it until he knocks it down.

Your task is to choose such an order of shooting so that the number of shots required to knock each of the n given cans down exactly once is minimum possible.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 1 000) — the number of cans.

The second line of the input contains the sequence a_1, a_2, ..., a_n (1 ≤ a_i ≤ 1 000), where a_i is the durability of the i-th can.

Output

In the first line print the minimum number of shots required to knock each of the n given cans down exactly once.

In the second line print the sequence consisting of n distinct integers from 1 to n — the order of indices of cans that minimizes the number of shots required. If there are several answers, you can print any of them.

Examples

Input


3
20 10 20


Output


43
1 3 2 


Input


4
10 10 10 10


Output


64
2 1 4 3 


Input


6
5 4 5 4 4 5


Output


69
6 1 3 5 2 4 


Input


2
1 4


Output


3
2 1 

Note

In the first example Vasya can start shooting from the first can. He knocks it down with the first shot because he haven't knocked any other cans down before. After that he has to shoot the third can. To knock it down he shoots 20 ⋅ 1 + 1 = 21 times. After that only second can remains. To knock it down Vasya shoots 10 ⋅ 2 + 1 = 21 times. So the total number of shots is 1 + 21 + 21 = 43.

In the second example the order of shooting does not matter because all cans have the same durability.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	static  ArrayList<Integer>adj[];
	
	public static void main(String[] args) throws Exception {
		Scanner sc=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=sc.nextInt();
		int a[]=new int[n];
		int count[]=new int[1001];
		adj=new ArrayList[1001];
		for (int i = 0; i < adj.length; i++) {
			adj[i]=new  ArrayList<>();
		}
		for (int i = 0; i < a.length; i++) {
			a[i]=sc.nextInt();
			count[a[i]]++;
		adj[a[i]].add(i+1);
		}
		
		Arrays.sort(a);
		long sum=0;
		ArrayList<Integer> l=new ArrayList<>();
		int idx=0;
		int cans=0;
		for (int i = a.length-1; i>=0; i--) {
			if(count[a[i]]==1) {
				l.add(adj[a[i]].get(0));
			idx=0;
			sum+=(a[i]*cans)+1;
           cans++;
			}
			else {
				idx=0;
				while(idx<adj[a[i]].size()) {
					sum+=(a[i]*cans)+1;
					l.add(adj[a[i]].get(idx));
					idx++;	
					cans++;	
				}
				i-=(idx-1);
			}
		}
		
		System.out.println(sum);
		for(int x:l) {
			System.out.print(x+" ");
		}
		
		
		
		
		out.flush();
	   
		
		
		
				
	   
	    
	     
	    
	        
			
				
	}
	
	
	static long mod=(long) (1e9+7);
	static boolean f2=false;
	static long[][] matMul(long[][] a2, long[][] b, int p, int q, int r)	//C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for(int i = 0; i < p; ++i) {
			for(int j = 0; j < r; ++j) {
				for(int k = 0; k < q; ++k) {
					C[i][j] = (C[i][j]+(a2[i][k]%mod * b[k][j]%mod))%mod;
		 C[i][j]%=mod;
				}
		
			}
		}
		return C;
	}
		static long query[];
	static long last1=0;
	static TreeSet<Long> x1;
	static HashMap<Long,Long> map;
	static long max=0;
	static int first=0;
	
	
	
		
		
		
		

		
	
	static ArrayList<Pair> a1[];
	static int memo1[];
	
	static boolean vis[];
	static TreeSet<Integer> set=new TreeSet<Integer>();
	static class Pair  implements Comparable<Pair>
	{
int x;int y;
		Pair(int n,int c){
			x=n;
			y=c;
		}
		@Override
		public int compareTo(Pair o) {
		if(o.x==x) {
			return o.y-y; 
		}
		else {
			return o.x-x;
		}
		}
		
		
		
	}	
	static long modPow(long ways, long count, long mod)	// O(log e)
	{
		ways %= mod;
		long res = 1;
		while(count > 0)
		{
			if((count & 1) == 1)
				res = (res * ways) % mod;
			ways = (ways * ways) % mod;
			count >>= 1;
		}
		return res%mod;
	}
	
	
	
	static  int  dx[] = {0,0,0,3,3,3,6,6,6};
	static int dy[] = {0,3,6,0,3,6,0,3,6};
	static int memo[][];
	static int a[];
	static int n;
	static int s;
	static boolean f[];

	static int gcd(int a,int b) {
		if(b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
	static int[] isComposite;
	static int[] valid;
	
	static ArrayList<Integer> primes;
	static ArrayList<Integer> l;
	static void sieve(int N)	// O(N log log N) 
	{
		isComposite = new int[N+1];					
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();
		l=new ArrayList<>();
		valid=new int[N+1];
		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N)) 
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				l.add(i);
				valid[i]=1;
				
				for (int j = i*2; j <=N; j +=i) {	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;
						
						
						
				      
					}
			}
		
		for(int i=0 ; i<primes.size() ; i++) {
			for(int j:primes) {
				if(primes.get(i)*j>N) {
					break;
				}
				valid[primes.get(i)*j]=1;
			}
		}
	}
	static char c[];
	static class UnionFind {                                              
		int[] p, rank, setSize;
		int numSets;

		public UnionFind(int N) 
		{
			p = new int[numSets = N];
			rank = new int[N];
			setSize = new int[N];
			for (int i = 0; i < N; i++) {  p[i] = i; setSize[i] = 1; }
		}

		public int findSet(int i) { return p[i] == i ? i : (p[i] = findSet(p[i])); }

		public boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }

		public void unionSet(int i, int j) 
		{ 
			if (isSameSet(i, j)) 
				return;
			numSets--; 
			int x = findSet(i), y = findSet(j);
			if(rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else
			{	p[x] = y; setSize[y] += setSize[x];
				if(rank[x] == rank[y]) rank[y]++; 
			} 
		}

		public int numDisjointSets() { return numSets; }

		public int sizeOfSet(int i) { return setSize[findSet(i)]; }
	}
	public static int[] schuffle(int[] a2) {
		for (int i = 0; i < a2.length; i++) {
			int x=(int)(Math.random()*a2.length);
		int temp=a2[x];
		a2[x]=a2[i];
		a2[i]=temp;
		}
		return a2;
	}
		static int V;
	static int INF=(int) 1E9;
		
		static class Edge2 
		{
			int node;
		long cost;
			long next;
			Edge2(int a, int c,Long long1) { node = a;	cost = long1; next=c;}
			
		}
static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}	
}
