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