#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long S = 0;
  vector<pair<int, int> > v;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    v.push_back((make_pair(A[i], i + 1)));
  }
  sort(v.begin(), v.end());
  for (int i = n - 1; i >= 0; i--) {
    S += v[i].first * (n - i - 1) + 1;
  }
  cout << S << endl;
  for (int i = n - 1; i >= 0; i--) {
    cout << v[i].second << " ";
  }
  return 0;
}
