#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<pair<int, int> > pi;
  for (int i = 0; i < n; i++) {
    pi.push_back(make_pair(arr[i], i + 1));
  }
  sort(pi.begin(), pi.end());
  vector<int> res;
  int l = pi.size();
  int sum = 0;
  int x = 0;
  for (int i = l - 1; i >= 0; i--) {
    sum += pi[i].first * x + 1;
    x++;
    res.push_back(pi[i].second);
  }
  cout << sum << endl;
  for (auto elem : res) cout << elem << " ";
  cout << endl;
}
