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