#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first)
    return true;
  else
    return false;
}
vector<pair<int, int> > g;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    g.push_back({a, i + 1});
  }
  sort(g.begin(), g.end(), comp);
  int tiro = 0;
  for (int i = 0; i < n; i++) {
    tiro += (i * g[i].first + 1);
  }
  cout << tiro << endl;
  for (int i = 0; i < n; i++) {
    cout << g[i].second << " ";
  }
  cout << endl;
}
