#include <bits/stdc++.h>
using namespace std;
bool isPrime(unsigned long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (unsigned long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
bool comp(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.push_back(make_pair(a, i + 1));
  }
  long long ans = 0;
  int x = 0;
  sort((v).begin(), (v).end(), comp);
  vector<long long> aa;
  aa.push_back(v[0].second);
  for (int i = 1; i < n; i++) {
    ans += v[i].first * i + 1;
    aa.push_back(v[i].second);
  }
  cout << ans + 1 << endl;
  for (auto i : aa) cout << i << " ";
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
