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