#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e7 + 11, M = 1e2 + 9;
const long long int LIMIT = 1 << 31;
unordered_map<string, long long int> cnt;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  pair<long long int, long long int> ar[n];
  for (long long int i = 1; i <= n; ++i) {
    cin >> ar[i - 1].first;
    ar[i - 1].second = i;
  }
  sort(ar, ar + n);
  long long int x = 0, cnt = 0;
  vector<long long int> ans;
  for (long long int i = n - 1; i >= 0; --i) {
    cnt += (x * ar[i].first + 1);
    ++x;
    ans.push_back(ar[i].second);
  }
  cout << cnt << endl;
  for (auto a : ans) cout << a << " ";
  return 0;
}
