#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
using namespace std;
int a[1001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i;
  long long cost = 0;
  vector<pair<int, int>> vec;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    vec.push_back(make_pair(a[i], i + 1));
  }
  sort(vec.begin(), vec.end());
  for (int i = n - 1; i >= 0; i--) {
    cost += (n - i - 1) * (vec[i].first) + 1;
  }
  int j = 1;
  cout << cost << "\n";
  for (int i = n - 1; i >= 0; i--) {
    cout << vec[i].second << " ";
  }
  cout << "\n";
}
