#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[400000];
int main() {
  int n = 0, m = 0, i = 0, j = 0, k = 0, t = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (i = 0; i < n; i++) {
    k += a[i].first * i + 1;
  }
  cout << k << endl;
  for (i = 0; i < n; i++) {
    cout << a[i].second + 1 << " ";
  }
  cout << endl;
}
