#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long a, n, flag = 0, ans = 0;
    cin >> n;
    vector<long long> v, v2;
    multimap<long long, long long> m;
    multimap<long long, long long>::iterator mp;
    for (long long i = 0; i < n; ++i) {
      long long a;
      cin >> a;
      v.push_back(a);
      m.insert(make_pair(a, i));
    }
    mp = m.end();
    mp--;
    for (; mp != m.begin(); mp--) {
      flag += (((mp->first) * ans) + 1);
      ans++;
      v2.push_back(mp->second + 1);
    }
    flag += (((mp->first) * ans) + 1);
    ans++;
    v2.push_back(mp->second + 1);
    cout << flag << '\n';
    for (long long i = 0; i < n; ++i) {
      cout << v2[i] << " ";
    }
  }
  return 0;
}
