#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int>& a, pair<int, int>& b) { return a.first > b.first; }
int main() {
  int n;
  cin >> n;
  pair<int, int> ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i].first;
    ar[i].second = i + 1;
  }
  sort(ar, ar + n, cmp);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (ar[i].first * i) + 1;
  }
  cout << sum << endl;
  for (int i = 0; i < n; ++i) {
    cout << ar[i].second << " ";
  }
  return 0;
}
