#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  long long x;
  for (long long int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(make_pair(x, i + 1));
  }
  sort(v.rbegin(), v.rend());
  long long sum = 0;
  for (long long int i = 0; i < n; i++) {
    sum += v[i].first * i + 1;
  }
  cout << sum << '\n';
  for (long long int i = 0; i < n; i++) cout << v[i].second << " ";
}
