#include <bits/stdc++.h>
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const double eps = 1e-8;
using namespace std;
struct node {
  int id;
  int val;
} a[maxn];
int n, t;
bool cmp(node a, node b) { return a.val < b.val; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].val);
    a[i].id = i + 1;
  }
  sort(a, a + n, cmp);
  long long sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += a[i].val * (n - i - 1) + 1;
  }
  printf("%lld\n", sum);
  for (int i = n - 1; i >= 0; i--) {
    printf("%d%c", a[i].id, i == 0 ? '\n' : ' ');
  }
  return 0;
}
