#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;
  vector<pair<int, int> > v(n);
  vector<int> sequence(n);
  for (int i = 0; i < n; i++) {
    pair<int, int> p;
    cin >> p.first;
    p.second = i + 1;
    v[i] = p;
  }
  sort(v.begin(), v.end(), cmp);
  int x = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    ans += v[i].first * x++ + 1;
    sequence[i] = v[i].second;
  }
  cout << ans << "\n";
  for (int i = 0; i < sequence.size(); i++) {
    cout << sequence[i] << " ";
  }
  return 0;
}
