#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, res = 0;
  cin >> n;
  vector<pair<long long, long long> > vet(n);
  vector<long long> res2(n);
  for (int i = 0; i < n; ++i) {
    cin >> vet[i].first;
    vet[i].second = i;
  }
  sort(vet.begin(), vet.end(),
       [](pair<long long, long long> a, pair<long long, long long> b) {
         if (a.first == b.first) {
           return a.second < b.second;
         }
         return a.first > b.first;
       });
  for (int i = 0; i < n; ++i) {
    res += vet[i].first * i + 1;
    res2[i] = vet[i].second + 1;
  }
  cout << res << "\n";
  for (int i = 0; i < n - 1; ++i) {
    cout << res2[i] << " ";
  }
  cout << res2.back() << "\n";
  return 0;
}
