#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  while (cin >> n && n) {
    int i, j;
    int a[10000];
    int b[10000];
    for (i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = i + 1;
    }
    for (i = 0; i < n - 1; i++) {
      for (j = 0; j < n - i - 1; j++) {
        if (a[j + 1] > a[j]) {
          int t = a[j + 1];
          a[j + 1] = a[j];
          a[j] = t;
          int temp = b[j + 1];
          b[j + 1] = b[j];
          b[j] = temp;
        }
      }
    }
    int sum = 1, flag = 1;
    for (i = 1; i < n; i++) {
      sum += a[i] * flag + 1;
      flag++;
    }
    cout << sum << endl;
    for (j = 0; j < n; j++) {
      if (j == 0)
        cout << b[j];
      else
        cout << " " << b[j];
    }
    cout << endl;
  }
  return 0;
}
