#include <bits/stdc++.h>
using namespace std;
struct px {
  int xb;
  int shuzhi;
} s[1001];
bool cmp(px x, px y) { return x.shuzhi > y.shuzhi; }
int main() {
  int i, n, sum = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i].shuzhi;
    s[i].xb = i;
  }
  sort(s + 1, s + n + 1, cmp);
  sum = 1;
  for (i = 2; i <= n; i++) {
    sum += (s[i].shuzhi * (i - 1) + 1);
  }
  cout << sum << endl;
  for (i = 1; i <= n; i++) cout << s[i].xb << " ";
}
