#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i, x = 0, ans, j, max;
  cin >> n;
  int arr[n], index[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  ans = 0;
  for (i = 0; i < n; i++) {
    max = 0;
    for (j = 0; j < n; j++) {
      if (arr[j] > max) {
        max = arr[j];
        index[i] = j + 1;
      }
    }
    arr[index[i] - 1] = 0;
    ans += ((x * max) + 1);
    x++;
  }
  cout << ans << "\n";
  for (i = 0; i < n; i++) {
    cout << index[i] << " ";
  }
  cout << "\n";
}
