#include <bits/stdc++.h>
using namespace std;
int main() {
  int j;
  int n;
  int ar1[1001];
  int ar[10000];
  scanf("%d", &n);
  int i;
  for (i = 0; i <= n - 1; i++) {
    scanf("%d", &ar[i]);
  }
  long long int res = 0;
  int maxx = -2;
  for (i = 0; i <= n - 1; i++) {
    if (ar[i] > maxx) {
      maxx = ar[i];
      j = i;
    }
  }
  res = res + 1;
  ar1[0] = j + 1;
  ar[j] = -3;
  for (int k = 1; k <= n - 1; k++) {
    maxx = -2;
    for (i = 0; i <= n - 1; i++) {
      if (ar[i] > maxx) {
        maxx = ar[i];
        j = i;
      }
    }
    res = res + (k * maxx + 1);
    ar1[k] = j + 1;
    ar[j] = -3;
  }
  printf("%lld\n", res);
  for (int h = 0; h <= n - 1; h++) {
    printf("%d ", ar1[h]);
  }
  return 0;
}
