#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<int> > v(1001);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v[a[i]].push_back(i + 1);
  }
  sort(a, a + n);
  int x = 0;
  int cost = 0;
  for (int i = n - 1; i >= 0; i--) {
    cost += x * a[i] + 1;
    ++x;
  }
  cout << cost << endl;
  for (int i = 1000; i >= 1; i--) {
    for (int j = 0; j < v[i].size(); j++) cout << v[i][j] << " ";
  }
}
