#include <bits/stdc++.h>
const int N = 1e3 + 1;
int a[N], b[N];
int n, max = 0, p, j;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (max < a[i]) {
      max = a[i];
      p = i;
    }
  }
  a[p] = 0;
  b[j] = p;
  int ans = 1;
  while (j < n - 1) {
    max = 0;
    for (int i = 1; i <= n; i++)
      if (max < a[i]) {
        max = a[i];
        p = i;
      }
    j++;
    ans += max * j + 1;
    a[p] = 0;
    b[j] = p;
  }
  printf("%d\n", ans);
  for (int j = 0; j <= n - 1; j++) printf("%d ", b[j]);
  return 0;
}
