#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
pair<int, int> p[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p + 1, p + 1 + n,
       [](pair<int, int> x, pair<int, int> y) { return x.first > y.first; });
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (i - 1) * p[i].first + 1;
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    cout << p[i].second << ' ';
  }
  return 0;
}
