#include <bits/stdc++.h>
using namespace std;
bool sort_pair(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first < b.first;
}
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> shots(n);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    shots[i] = {a, i};
  }
  sort(shots.rbegin(), shots.rend(), sort_pair);
  long result = 0l;
  vector<int> indices(n);
  for (int i = 0; i < n; ++i) {
    result += shots[i].first * i + 1;
    indices[i] = shots[i].second;
  }
  cout << result << endl;
  for (int index : indices) {
    cout << index + 1 << " ";
  }
  cout << endl;
  return 0;
}
