#include <bits/stdc++.h>
using namespace std;
typedef struct test_t {
  int value;
  int index;
} test_t;
bool myfunction(test_t i, test_t j) { return (i.value > j.value); }
int main() {
  int n, ans = 0;
  cin >> n;
  int tmp[n];
  vector<test_t> c;
  for (int i = 0; i < n; i++) {
    cin >> tmp[i];
    c.push_back({tmp[i], i});
  }
  sort(c.begin(), c.end(), myfunction);
  for (int i = 0; i < n; i++) {
    ans += (c[i].value * i + 1);
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    cout << c[i].index + 1 << " ";
  }
  return 0;
}
