#include <bits/stdc++.h>
using namespace std;
int v[1001], a[1001];
int main() {
  int n, i, j, k, l = 1, c = 0, s = 0, maxim = 0, ok = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> v[i];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (maxim < v[j]) {
        maxim = v[j];
        k = j;
        ok = 1;
      }
    }
    if (ok == 1) s = s + maxim * c + 1;
    ok = 0;
    c++;
    a[l] = k;
    l++;
    v[k] = 0;
    maxim = 0;
  }
  cout << s << '\n';
  for (i = 1; i <= l - 1; i++) cout << a[i] << " ";
  return 0;
}
