#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (a > 0 && b > 0)
    if (a > b)
      a %= b;
    else
      b %= a;
  return a + b;
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long visited[100000];
int main() {
  vector<pair<int, int>> vec;
  vector<int> vec2;
  int n;
  cin >> n;
  int x;
  for (int a = 0; a < n; a++) {
    scanf("%d", &x);
    vec.push_back({x, a});
  }
  sort((vec).begin(), (vec).end());
  int res = 0;
  vec[n - 1].first = 0;
  res++;
  vec2.push_back(vec[n - 1].second + 1);
  int ct = 1;
  for (int a = n - 2; a >= 0; a--) {
    res += ct * vec[a].first + 1;
    vec2.push_back(vec[a].second + 1);
    ct++;
  }
  cout << res << "\n";
  for (int a = 0; a < n; a++) {
    printf("%d ", vec2[a]);
  }
  return 0;
}
