#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x = 0, sum = 0, l;
  cin >> n;
  int arr[1000];
  int y[1000];
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) {
    l = 0;
    m = 0;
    for (int j = 0; j < n; j++)
      if (arr[j] > m) {
        m = arr[j];
        l = j;
      }
    arr[l] = 0;
    sum += m * x + 1;
    y[i] = l + 1;
    x++;
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) cout << y[i] << " ";
  return 0;
}
