#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  pair<long long int, long long int> a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a, a + n);
  long long int ans = 0;
  long long int c = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    ans += a[i].first * c + 1;
    c++;
  }
  cout << ans << "\n";
  for (long long int i = n - 1; i >= 0; i--) cout << a[i].second + 1 << " ";
  return 0;
}
