#include <bits/stdc++.h>
using namespace std;
long long n, c, res;
struct gg {
  long long k;
  long long x;
};
gg a[1007];
bool cmp(gg z, gg y) { return z.k > y.k; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].k;
    a[i].x = i;
  }
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    res += a[i].k * c + 1;
    c++;
  }
  cout << res << endl;
  for (int i = 1; i <= n; i++) {
    cout << a[i].x << " ";
  }
  return 0;
}
