#include <bits/stdc++.h>
using namespace std;
const long long INF = (1e18);
const int N = (2 * (1e5));
int n;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  pair<int, int> p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p, p + n);
  int ans = 0;
  int a[n];
  for (int i = n - 1; i >= 0; i--) {
    int x = n - 1 - i;
    ans += p[i].first * x + 1;
    a[x] = p[i].second + 1;
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;
}
