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