#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k = 0, an = 0;
  cin >> n;
  int a[n], b[n], c[n], t = 0, p = 0;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) b[i] = a[i];
  sort(a, a + n);
  for (int i = n - 1; i >= 0; --i) {
    an = an + k * a[i] + 1;
    for (int j = 0; j < n; ++j)
      if (a[i] == b[j]) {
        c[p++] = j + 1;
        b[j] = -1;
      }
    k++;
  }
  cout << an << endl;
  for (int i = 0; i < n; ++i) cout << c[i] << " ";
  return 0;
}
