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