#include <bits/stdc++.h>
using namespace std;
const long long base = 1e18 + 7;
const long long MAX_N = 1005;
long long dd[MAX_N + 1];
long long dp[MAX_N + 1];
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first > b.first;
}
void Solves() {
  long long n;
  long long t;
  long long q;
  cin >> n;
  pair<long long, long long> a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1, cmp);
  long long ans = 1;
  long long st = 1;
  for (int i = 2; i <= n; i++) {
    ans += st * a[i].first + 1;
    st++;
  }
  cout << ans << "\n";
  for (int i = 1; i <= n; i++) cout << a[i].second << " ";
}
int main() { Solves(); }
