#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += b[i] * i + 1;
  }
  cout << sum << endl;
  for (long long i = 2000; i >= 0; i--) {
    for (long long j = 0; j < n; j++) {
      if (a[j] == i) {
        cout << j + 1 << " ";
      }
    }
  }
  return 0;
}
