#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[1005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a, a + n, greater<pair<int, int>>());
  int res = 0;
  for (int i = 0; i < n; i++) res += i * a[i].first + 1;
  printf("%d\n", res);
  for (int i = 0; i < n; i++) {
    if (i == 0)
      printf("%d", a[i].second + 1);
    else
      printf(" %d", a[i].second + 1);
  }
  printf("\n");
}
