#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000000;
using Graph = vector<vector<long long>>;
signed main() {
  long long N;
  cin >> N;
  vector<pair<long long, long long>> A(N);
  for (long long i = 0; i < (long long)(N); i++) {
    long long a;
    cin >> a;
    A[i] = {a, i};
  }
  sort(A.rbegin(), A.rend());
  long long ans = 0;
  vector<long long> B;
  for (long long i = 0; i < (long long)(N); i++) {
    ans += A[i].first * i + 1;
    B.emplace_back(A[i].second + 1);
  }
  cout << ans << "\n";
  for (long long i = 0; i < (long long)(N); i++) cout << B[i] << " ";
  cout << "\n";
}
