#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, sum = 0;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(make_pair(a, i + 1));
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < n; i++) {
    sum = sum + (v[i].first * i) + 1;
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) {
    cout << v[i].second << " ";
  }
}
