#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n];
  int real[n];
  int rank[n];
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    real[i] = x[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      if (x[j + 1] > x[j]) {
        int temp = x[j + 1];
        x[j + 1] = x[j];
        x[j] = temp;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (x[i] == real[j]) {
        rank[i] = j + 1;
        real[j] = 0;
        break;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += (x[i] * i + 1);
  }
  cout << sum << endl;
  for (int i = 0; i < n; ++i) {
    cout << rank[i] << " ";
  }
  return 0;
}
