#include <bits/stdc++.h>
using namespace std;
int main() {
  ofstream out("output.txt");
  auto start = chrono::high_resolution_clock::now();
  long long t = 1;
  for (long long test = 1; test <= t; test++) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    pair<long long, long long> b[n];
    for (long long i = 0; i <= n - 1; i++)
      cin >> a[i], b[i].first = a[i], b[i].second = i;
    sort(b, b + n);
    long long ord[n];
    long long shts = 0, I = 0;
    for (long long i = n - 1; i >= 0; i--) {
      shts += (b[i].first * I + 1);
      ord[I] = b[i].second + 1;
      I++;
    }
    cout << shts << "\n";
    for (long long i = 0; i <= n - 1; i++) cout << ord[i] << " ";
    cout << "\n";
  }
  auto stop = chrono::high_resolution_clock::now();
}
