#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long str[n + 4], s[n + 4];
  for (int i = 0; i < n; i++) {
    cin >> str[i];
    s[i] = str[i];
  }
  sort(s, s + n);
  long long ans = 0;
  int k = 0;
  for (int i = n - 1; i >= 0; i--) {
    ans += (s[i] * k) + 1;
    k++;
  }
  cout << ans << endl;
  for (int i = n - 1; i >= 0; i--) {
    long long ss = s[i];
    for (int j = 0; j < n; j++) {
      if (ss == str[j]) {
        cout << j + 1 << " ";
        str[j] = -1000;
      }
    }
  }
  cout << endl;
}
