#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  int co = 0;
  for (int i = 0; i < n; i++) {
    co += b[i] * i + 1;
    int j;
    for (j = 0; j < n; j++) {
      if (a[j] == b[i]) {
        a[j] = -1;
        break;
      }
    }
    c[i] = ++j;
  }
  cout << co << endl;
  for (int i = 0; i < n; i++) {
    cout << c[i] << " ";
  }
}
