#include <bits/stdc++.h>
using namespace std;
const int N = int(3e5) + 2;
const int LG = 20;
const long long mod = (int)1e8;
const int INF = (int)1e9 + 7;
const long long linf = 1e15;
const long double pi = acos(-1);
const int base = 10;
const long double EPS = 1e-9;
int n, used[1005];
pair<int, int> a[1005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  long long sum = 0;
  vector<int> ans;
  for (int i = 1; i <= n; ++i) {
    sum += ((a[i].first * (i - 1)) + 1);
    ans.push_back(a[i].second);
  }
  printf("%lld\n", sum);
  for (int to : ans) printf("%d ", to);
  return 0;
}
