#include <bits/stdc++.h>
using namespace std;
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  long long int a[n], sum = 0;
  vector<pair<int, int> > vec;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    vec.push_back(make_pair(a[i], i + 1));
  }
  sort(vec.begin(), vec.end(), sortinrev);
  vector<pair<int, int> >::iterator it;
  int z = 0;
  for (it = vec.begin(); it != vec.end(); it++) {
    sum += it->first * z + 1;
    z++;
  }
  cout << sum << '\n';
  for (it = vec.begin(); it != vec.end(); it++) {
    cout << it->second << " ";
  }
}
