#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, i, j, k, l = 0;
  pair<int, int> p;
  vector<pair<int, int> > v;
  cin >> a;
  for (i = 1; i <= a; i++) {
    cin >> b;
    p.first = b;
    p.second = i;
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  for (i = a - 2, j = 1; i >= 0; i--, j++) {
    l += (v[i].first * (j)) + 1;
  }
  l++;
  cout << l << endl;
  for (i = a - 1; i >= 0; i--) {
    cout << v[i].second << " ";
  }
}
