#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long f = 1;
  if (y % 2 == 0) f = 0;
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  if (f)
    return res;
  else
    return res - 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, j, s = 0, x;
  cin >> n;
  vector<pair<long long, long long>> v;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(make_pair(x, i + 1));
  }
  sort(v.rbegin(), v.rend());
  long long tot = 1;
  vector<long long> ans;
  ans.push_back(v[0].second);
  for (i = 1; i < n; i++) {
    tot = tot + i * v[i].first + 1;
    ans.push_back(v[i].second);
  }
  cout << tot << "\n";
  for (long long x : ans) cout << x << " ";
  return 0;
}
