#include <bits/stdc++.h>
using namespace std;
void s_y_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void write(T&&... args) {
  ((cout << args << " "), ...);
}
void solve() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > vect(n);
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    vect[i] = {x, i + 1};
  }
  sort(vect.rbegin(), vect.rend());
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans += i * vect[i].first + 1;
  }
  cout << ans << '\n';
  for (long long i = 0; i < n; i++) {
    cout << vect[i].second << ' ';
  }
}
int32_t main() {
  s_y_c();
  long long t;
  t = 1;
  while (t--) solve();
  return 0;
}
