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