#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, kase, tc, n, m;
  scanf("%d", &n);
  vector<int> v(n);
  for (i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  vector<int> a = v;
  sort(v.rbegin(), v.rend());
  long long sum = 0;
  for (i = 0; i < n; i++) {
    sum = sum + ((v[i] * i) + 1);
  }
  cout << sum << endl;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (v[i] == a[j]) {
        a[j] = -1;
        cout << j + 1 << " ";
        break;
      }
    }
  }
  return 0;
}
