#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[1000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int b[1000];
  for (int i = 0; i < n; i++) {
    b[i] = a[i];
  }
  sort(a, a + n, greater<int>());
  int shots = 0;
  for (int i = 0; i < n; i++) {
    shots = shots + a[i] * i + 1;
  }
  cout << shots << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (b[j] == a[i]) {
        cout << j + 1 << " ";
        b[j] = 0;
      }
    }
  }
  return 0;
}
