#include <bits/stdc++.h>
using namespace std;
struct compare {
  bool operator()(const pair<long long int, long long int> &l,
                  const pair<long long int, long long int> &r) {
    if (l.first == r.first) return l.second > r.second;
    return l.first > r.first;
  }
};
priority_queue<long long int, vector<long long int>, greater<long long int> >
    pq;
long long int min(long long int a, long long int b) { return a <= b ? a : b; }
long long int max(long long int a, long long int b) { return a >= b ? a : b; }
long long int abso(long long int n) { return n >= 0 ? n : -n; }
int ar[1002];
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int ans = 0;
  vector<pair<int, int> > V;
  V.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> V[i].first;
    V[i].second = i;
  }
  sort(V.begin(), V.end());
  for (int i = n - 1; i >= 0; i--) {
    ans += (n - i - 1) * V[i].first + 1;
  }
  cout << ans << "\n";
  for (int i = n - 1; i >= 0; i--) {
    cout << V[i].second + 1 << " ";
  }
  cout << "\n";
}
