#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b % 2 != 0) res = (res * a) % 998244353;
    a = (a * a) % 998244353;
    b /= 2;
  }
  return res;
}
long long ncr(long long n, long long k) {
  if (k == 0 || k == n) return 1ll;
  if (k > n - k) k = n - k;
  long long pro = 1;
  for (long long i = 0; i < k; i++) {
    pro = (pro * (n - i)) % 998244353;
    pro /= (i + 1);
  }
  return (pro % 998244353);
}
vector<int> prime;
void seive() {
  vector<bool> isprime(1000001, true);
  for (int i = 2; i * i <= 1000000; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= 1000000; j += i) {
        isprime[j] = false;
      }
    }
  }
  for (int i = 2; i <= 1000000; i++) {
    if (isprime[i]) prime.push_back(i);
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, a;
  cin >> n;
  vector<pair<long long, long long> > arr(n);
  vector<long long> ans;
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr[i] = {a, i + 1};
  }
  sort(arr.begin(), arr.end(), greater<pair<long long, long long> >());
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += (i * arr[i].first + 1);
    ans.push_back(arr[i].second);
  }
  cout << cnt << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
