#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, sum = 0, x = 0;
  cin >> n;
  vector<int> v(n), u(n);
  for (auto &&i : v) {
    cin >> i;
  }
  for (int i = 0; i < n; i++) {
    auto l = max_element(v.begin(), v.end());
    u[i] = distance(v.begin(), max_element(v.begin(), v.end()));
    sum += (*l) * x + 1;
    *l = 0;
    ++x;
  }
  cout << sum << '\n';
  for (int i = 0; i < n; i++) {
    cout << u[i] + 1 << " ";
  }
  return 0;
}
