#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;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCl7CglpbnQgbix4LHQ9MCxjID0gMDsJY2luID4+IG47Cgl2ZWN0b3I8cGFpcjxpbnQsaW50Pj4gczsKCWZvcihpbnQgaT0wO2k8bjtpKyspewoJCWNpbiA+PiB4OwoJCXMucHVzaF9iYWNrKHt4LGkrMX0pOwoJCS8vY291dCA8PCB4IDw8ICIgIiA8PCBpKzEgPDwgZW5kbDsKCX0KCXNvcnQocy5iZWdpbigpLHMuZW5kKCksZ3JlYXRlcjw+KCkpOwoJZm9yKGF1dG8gaXQgPSBzLmJlZ2luKCk7aXQgIT0gcy5lbmQoKTsrK2l0KXsKCQl0ICs9IGl0LT5maXJzdCAqIGMgKyAxOwoJCSsrYzsKCX0KCWNvdXQgPDwgdCA8PCBlbmRsOwoJZm9yKGF1dG8gaXQgPSBzLmJlZ2luKCk7aXQgIT0gcy5lbmQoKTsrK2l0KQljb3V0IDw8IGl0LT5zZWNvbmQgPDwgIiAiOwoJcmV0dXJuIDA7Cn0=