#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.begin(), v.end(),
       [](pair<int, int> a, pair<int, int> b) { return a.first > b.first; });
  int count = 0, sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += v[i].first * count + 1;
    count++;
  }
  cout << sum << endl;
  for (auto& p : v) {
    cout << p.second + 1 << " ";
  }
  cout << endl;
  return 0;
}
