#include <bits/stdc++.h>
using namespace std;
bool compare(pair<int, int> A, pair<int, int> B) { return A.first > B.first; }
void findorder(vector<pair<int, int> > A, int N) {
  int ans = 0;
  sort(A.begin(), A.end(), compare);
  for (int i = 0; i < N; i++) ans += (i * A[i].first) + 1;
  cout << ans << endl;
  for (int i = 0; i < N; i++) cout << A[i].second << " ";
  cout << endl;
}
int main() {
  int N;
  cin >> N;
  vector<pair<int, int> > A;
  for (int i = 0; i < N; i++) {
    int temp;
    cin >> temp;
    A.push_back(make_pair(temp, i + 1));
  }
  findorder(A, N);
  return 0;
}
