#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
int main() {
  int n;
  cin >> n;
  pair<int, int> arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first;
    arr[i].second = i;
  }
  sort(arr, arr + n, cmp);
  long long total = 0;
  for (int i = 0; i < n; i++) total += ((arr[i].first * i) + 1);
  cout << total << endl;
  for (int i = 0; i < n; i++) cout << (arr[i].second + 1) << " ";
  cout << endl;
}
