#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,x,t=0,c = 0;	cin >> n;
	vector<pair<int,int>> s;
	for(int i=0;i<n;i++){
		cin >> x;
		s.push_back({x,i+1});
		//cout << x << " " << i+1 << endl;
	}
	sort(s.begin(),s.end(),greater<>());
	for(auto it = s.begin();it != s.end();++it){
		t += it->first * c + 1;
		++c;
	}
	cout << t << endl;
	for(auto it = s.begin();it != s.end();++it)	cout << it->second << " ";
	return 0;
}