#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int> > a;
  for (int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    a.push_back(make_pair(c, i + 1));
  }
  sort(a.begin(), a.end());
  int ans = 0, x = 0;
  for (int i = n - 1; i >= 0; --i) {
    ans += a[i].first * x + 1;
    x++;
  }
  cout << ans << endl;
  for (int i = n - 1; i >= 0; --i) {
    cout << a[i].second << " ";
  }
}
int main() {
  { solve(); }
}
