#include <bits/stdc++.h>
using namespace std;
bool comparator(const std::pair<int, int>& l, const std::pair<int, int>& r) {
  return l.first > r.first;
}
int main() {
  int n, a;
  cin >> n;
  vector<pair<int, int>> inpvector;
  for (int j = 0; j < n; j++) {
    cin >> a;
    inpvector.push_back(make_pair(a, j));
  }
  sort(inpvector.begin(), inpvector.end(), comparator);
  int cost = 0;
  for (int j = 0; j < n; j++) {
    cost += (inpvector[j].first) * j + 1;
  }
  cout << cost << endl;
  for (int j = 0; j < n; j++) {
    cout << inpvector[j].second + 1 << " ";
  }
  cout << endl;
  return 0;
}
