#include <bits/stdc++.h>
int n;
long long ans;
struct cz {
  int x, s;
} a[1005];
bool cmp(cz c, cz d) {
  if (c.s == d.s)
    return c.x < d.x;
  else
    return c.s > d.s;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i].s);
    a[i].x = i;
  }
  std::sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; ++i) ans = ans + 1ll * (i - 1) * a[i].s + 1;
  std::cout << ans << '\n';
  for (int i = 1; i <= n; ++i) printf("%d ", a[i].x);
  putchar('\n');
  return 0;
}
