#include <bits/stdc++.h>
using namespace std;
template <class T>
bool smax(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool smin(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < (int)(n); ++i) {
    int x;
    cin >> x;
    a[i] = make_pair(x, i + 1);
  }
  sort(a.rbegin(), a.rend());
  int cnt = 0;
  int ans = 0;
  vector<int> out;
  for (int i = 0; i < (int)(n); ++i) {
    ans += cnt * a[i].first + 1;
    cnt++;
    out.push_back(a[i].second);
  }
  cout << ans << '\n';
  for (int i = 0; i < (int)(out.size()); ++i) cout << out[i] << " ";
  cout << '\n';
  return 0;
}
