#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, temp;
  cin >> n;
  vector<pair<long long int, long long int>> v;
  for (int i = 1; i <= n; i++) {
    cin >> temp;
    v.push_back(make_pair(temp, i));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (i * (v[i].first) + 1);
  }
  cout << ans << "\n";
  for (int i = 0; i < n; i++) cout << v[i].second << " ";
  cout << "\n";
}
