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