#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
struct node {
  int x;
  int p;
};
struct node a[1005];
int cmp(node a, node b) { return a.x > b.x; }
long long fpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i].x);
      a[i].p = i;
    }
    sort(a + 1, a + n + 1, cmp);
    int sum = 0;
    int count = 0;
    for (int i = 1; i <= n; i++) {
      sum += count * a[i].x + 1;
      count++;
    }
    printf("%d\n", sum);
    for (int i = 1; i <= n; i++) printf("%d ", a[i].p);
    printf("\n");
  }
}
