#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  pair<long long, long long> a[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  long long ans = 0;
  sort(a, a + n, greater<pair<long long, long long>>());
  for (long long i = 0; i < n; ++i) {
    ans += (i * a[i].first) + 1;
  }
  cout << ans << "\n";
  long long b[n];
  for (long long i = 0; i < n; ++i) {
    b[a[i].second] = i + 1;
  }
  for (long long i = 0; i < n; ++i) {
    cout << a[i].second + 1 << " ";
  }
}
