#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
long long int ans = 0, a[N];
pair<long long int, long long int> p[N];
int main() {
  long long int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    p[i] = make_pair(a[i], i);
  }
  sort(a, a + n);
  long long int po = n - 1, sh = 0, ni = 1;
  while (po >= 0) {
    sh++;
    ans++;
    if (sh == ni) {
      po--;
      sh = 0;
      if (po != -1) ni = a[po] * (n - po - 1) + 1;
    }
  }
  sort(p, p + n);
  cout << ans << '\n';
  for (int i = n - 1; i >= 0; i--) {
    cout << p[i].second + 1 << ' ';
  }
}
