#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back({x, i + 1});
  }
  sort(v.rbegin(), v.rend());
  int ans = 0;
  for (int i = 0; i < n; i++) ans += i * v[i].first + 1;
  cout << ans << endl;
  for (auto x : v) cout << x.second << " ";
  return 0;
}
