#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, vector<int>> umap;
  map<int, vector<int>>::reverse_iterator it;
  int n, i;
  int a[1009];
  vector<int> b;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    if (umap.find(a[i]) == umap.end()) {
      umap[a[i]] = vector<int>();
    }
    umap[a[i]].push_back(i);
  }
  int r = 0, shots = 0;
  for (it = umap.rbegin(); it != umap.rend(); it++) {
    for (auto j : it->second) {
      shots += (it->first) * r + 1;
      r++;
      b.push_back(j + 1);
    }
  }
  cout << shots << endl;
  for (auto x : b) cout << x << " ";
  return 0;
}
