#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, i;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (i = 0; i < n; i++) {
    long long x;
    cin >> x;
    v.push_back({x, i + 1});
  }
  long long x = 0, cnt = 0;
  vector<long long> ans;
  sort(v.begin(), v.end());
  for (i = n - 1; i >= 0; i--) {
    cnt += v[i].first * x + 1;
    x++;
    ans.push_back(v[i].second);
  }
  cout << cnt << "\n";
  for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
