#include <bits/stdc++.h>
using namespace std;
bool bysec(const pair<int64_t, int64_t> &a, pair<int64_t, int64_t> &b) {
  return a.first > b.first;
}
void solve() {
  int64_t n, x, an = 0;
  cin >> n;
  pair<int64_t, int64_t> A[n];
  for (int64_t i = 0; i < n; i++) cin >> x, A[i] = {x, i + 1};
  sort(A, A + n, bysec);
  for (int64_t i = 0; i < n; i++) an += i * A[i].first + 1;
  cout << an << "\n";
  for (int64_t i = 0; i < n; i++) cout << A[i].second << " ";
  cout << "\n";
}
signed main() {
  int64_t T = 1;
  while (T--) solve();
  return 0;
}
