#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, total = 0;
  pair<int, int> arr[1000 + 10];
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first;
    arr[i].second = i;
  }
  sort(arr, arr + n, greater<pair<int, int> >());
  for (int i = 0; i < n; i++) {
    total += arr[i].first * i + 1;
    v.push_back(arr[i].second + 1);
  }
  cout << total << '\n';
  for (int i = 0; i < (int)v.size(); i++) cout << v[i] << ' ';
  return 0;
}
