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