#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[1000];
  int i;
  int j;
  int temp;
  int temp2;
  int sum = 0;
  int b[1000];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = i;
  }
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < n - 1 - i; j++) {
      if (a[j] > a[j + 1]) {
        temp = a[j];
        a[j] = a[j + 1];
        a[j + 1] = temp;
        temp2 = b[j];
        b[j] = b[j + 1];
        b[j + 1] = temp2;
      }
    }
  }
  int x = 0;
  for (i = n - 1; i >= 0; i--) {
    sum = sum + a[i] * x + 1;
    x++;
  }
  cout << sum;
  cout << "\n";
  for (i = n - 1; i >= 0; i--) {
    cout << b[i] + 1;
    cout << " ";
  }
}
