#include <bits/stdc++.h>
using namespace std;
inline void speed() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int compare(pair<long long int, long long int> a,
            pair<long long int, long long int> b) {
  return a.first > b.first;
}
int main() {
  speed();
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > a;
  for (long long int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    a.push_back({temp, i});
  }
  sort(a.begin(), a.end(), compare);
  long long int k = 0;
  long long int tk = 0;
  for (long long int i = 0; i < n; i++) {
    k = (a[i].first) * i + 1;
    tk += k;
  }
  cout << tk << "\n";
  for (long long int i = 0; i < n; i++) {
    cout << a[i].second + 1 << " ";
  }
  return 0;
}
