#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int x, index;
} a[1010];
bool cmp(node x, node y) {
  if (x.x != y.x)
    return x.x > y.x;
  else
    return x.index > y.index;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].x);
    a[i].index = i;
  }
  sort(a + 1, a + n + 1, cmp);
  int SUM = 0;
  for (int i = 1; i <= n; i++) {
    SUM += ((i - 1) * a[i].x + 1);
  }
  printf("%d\n", SUM);
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i].index);
  }
}
