#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> p1, pair<int, int> p2) { return p1.first > p2.first; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  vector<pair<int, int> > v;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int _;
    cin >> _;
    v.push_back(make_pair(_, i));
  }
  sort(v.begin(), v.end(), cmp);
  int x = 0, sum = 0, sz = v.size() - 1;
  for (int i = 0; i <= sz; i++) {
    sum += v[i].first * x + 1;
    x++;
  }
  cout << sum << endl;
  for (int i = 0; i <= sz; i++) {
    cout << v[i].second << (i == sz ? "\n" : " ");
  }
  return 0;
}
