#include <bits/stdc++.h>
using namespace std;
const int modd = 400000002;
struct node {
  int a;
  int id;
} can[1010];
int n;
bool cmp(node a, node b) { return a.a > b.a; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &can[i].a);
    can[i].id = i;
  }
  sort(can + 1, can + 1 + n, cmp);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += (i - 1) * can[i].a + 1;
  }
  printf("%lld\n", sum);
  printf("%d", can[1].id);
  for (int i = 2; i <= n; i++) {
    printf(" %d", can[i].id);
  }
  printf("\n");
  return 0;
}
