#include <bits/stdc++.h>
using namespace std;
vector<long long> divisor(long long n) {
  vector<long long> v;
  for (int i = 0; i <= sqrt(n); i++) {
    if (n % i == 0)
      if (n / i == i)
        v.push_back(i);
      else {
        v.push_back(i);
        v.push_back(n / i);
      }
  }
  return v;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
vector<long long> sieve() {
  vector<long long> v(1000001);
  int i, j;
  for (i = 0; i < 1000001; i++) v[i] = 1;
  for (i = 2; i <= sqrt(1000001); i++)
    if (v[i] == 1)
      for (j = i * i; j <= 1000000; j += i) v[j] = 0;
  v[1] = 0;
  return v;
}
const long long N = 2e5 + 5;
long long arr[N], dp1[N], dp2[N];
int main() {
  long long a, b = 31, c, d, e, sum = 0, count = 0, flag = 0, j = 0, i = 1;
  long long x, y;
  set<long long> se;
  long long n, m, t, k, l, r;
  string s, second;
  vector<long long> v;
  cin >> n;
  pair<long long, long long> p[n];
  for (i = 0; i < n; i++) {
    cin >> a;
    p[i].first = a;
    p[i].second = i + 1;
  }
  sort(p, p + n);
  reverse(p, p + n);
  for (i = 0; i < n; i++) {
    sum += (p[i].first * count) + 1;
    count++;
  }
  cout << sum << "\n";
  for (i = 0; i < n; i++) cout << p[i].second << " ";
}
