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