#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, a;
  cin >> n;
  vector<pair<int, int>> nums(0);
  for (long long i = 0; i < n; i++) {
    cin >> a;
    nums.push_back(make_pair(a, i + 1));
  }
  sort(nums.begin(), nums.end());
  long long int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    ans += (((nums[i].first) * (n - 1 - i)) + 1);
  }
  cout << ans << '\n';
  for (int i = n - 1; i >= 0; i--) cout << nums[i].second << ' ';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TC;
  TC = 1;
  for (int t = 0; t < TC; t++) solve();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
