#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j = 0, sum = 0;
  int a[1000];
  int b[1000];
  cin >> n >> a[0];
  b[0] = 1;
  for (i = 1; i < n; i++) {
    cin >> a[i];
    b[i] = i + 1;
    int k1 = a[i];
    int k2 = b[i];
    j = i - 1;
    while (j >= 0 && a[j] < k1) {
      a[j + 1] = a[j];
      b[j + 1] = b[j];
      j--;
    }
    a[j + 1] = k1;
    b[j + 1] = k2;
  }
  for (i = 0; i < n; i++) {
    sum = sum + (a[i] * i + 1);
  }
  cout << sum << endl;
  for (i = 0; i < n; i++) cout << b[i] << " ";
}
