#include <bits/stdc++.h>
using namespace std;
int bi[1001] = {0};
int a[1001] = {0};
void qsort(int l, int r) {
  int i = l, j = r, x = a[(l + r) / 2];
  while (i <= j) {
    while (a[i] < x) ++i;
    while (a[j] > x) --j;
    if (i <= j) {
      swap(a[i], a[j]);
      swap(bi[i], bi[j]);
      ++i;
      --j;
    }
  }
  if (i < r) qsort(i, r);
  if (l < j) qsort(l, j);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    bi[i] = i + 1;
  }
  int x = 0;
  qsort(0, n - 1);
  int kq = 0;
  for (int i = n - 1; i >= 0; --i) {
    kq += (a[i] * x) + 1;
    ++x;
  }
  cout << kq << endl;
  for (int i = n - 1; i >= 0; --i) {
    cout << bi[i] << " ";
  }
  return 0;
}
