#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 100;
const long long MOD = 1e9;
struct node {
  long long val, pos;
  bool operator<(const node b) const {
    if (val == b.val) return pos < b.pos;
    return val > b.val;
  }
} arr[MAXN];
int ans[MAXN] = {0};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i].val, arr[i].pos = i + 1;
  sort(arr, arr + n);
  long long rans = 0;
  for (int i = 0; i < n; ++i) {
    rans += (i * arr[i].val + 1);
  }
  cout << rans << '\n';
  for (int i = 0; i < n; ++i) cout << arr[i].pos << ' ';
  return 0;
}
