#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> cnt(1001);
int main() {
  int n, temp, sum = 0, y = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> temp;
    cnt[temp].push_back(i);
  }
  for (int i = 1000; i > 0; i--) {
    for (int x : cnt[i]) {
      sum += (i * y + 1);
      y++;
    }
  }
  cout << sum << endl;
  for (int i = 1000; i > 0; i--) {
    for (int x : cnt[i]) cout << x << " ";
  }
  cout << endl;
  return 0;
}
