#include <bits/stdc++.h>
using namespace std;
int n;
long long total;
vector<pair<int, int> > a;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; ++i) {
    total += a[i].first * i + 1;
  }
  cout << total << "\n";
  for (int i = 0; i < n; ++i) {
    cout << a[i].second + 1 << " \n"[i == n - 1];
  }
  return 0;
}
