#include <bits/stdc++.h>
using namespace std;
bool fun(const pair<int, int> &p1, const pair<int, int> &p2) {
  return (p1.second < p2.second);
}
int main() {
  int n, i, j, ans;
  cin >> n;
  pair<int, int> p[n + 1];
  for (i = 1; i <= n; ++i) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p + 1, p + n + 1, greater<pair<int, int>>());
  ans = 0;
  for (i = 1; i <= n; ++i) {
    ans = ans + 1 + p[i].first * (i - 1);
  }
  cout << ans << "\n";
  for (i = 1; i <= n; ++i) cout << p[i].second << " ";
  return 0;
}
