#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> vp;
int n, ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 0, u, v; i < n; i++) cin >> u, vp.push_back({u, i});
  sort(vp.begin(), vp.end());
  reverse(vp.begin(), vp.end());
  for (int i = 0; i < n; i++) ans += (vp[i].first * i) + 1;
  cout << ans << '\n';
  for (auto [a, b] : vp) cout << b + 1 << ' ';
  return 0;
}
