#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long quickmod(long long a, long long n) {
  long long s = 1;
  while (n) {
    if (n & 1) {
      s = s * a % mod;
    }
    a = (a * a) % mod;
    n = n / 2;
  }
  return s;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
bool isPrime(long long x) {
  if (x <= 1) return false;
  if (x == 2) return true;
  if (x % 2 == 0) return false;
  long long i, m;
  m = sqrt(x);
  for (i = 2; i <= m; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
const int N = 1e3 + 5;
int t;
int n;
struct node {
  int x;
  int y;
} a[N];
bool cmp(node a, node b) { return a.x < b.x; }
int main() {
  while (cin >> n) {
    for (register int i = 1; i <= n; ++i) {
      scanf("%d", &a[i].x);
      a[i].y = i;
    }
    sort(a + 1, a + n + 1, cmp);
    long long ans = 0;
    for (register int i = n; i >= 1; --i) {
      ans += a[i].x * (n - i) + 1;
    }
    cout << ans << endl;
    for (register int i = n; i >= 1; --i) cout << a[i].y << " ";
  }
  return 0;
}
