#include <bits/stdc++.h>
using namespace std;
int n, a[1003];
pair<int, int> p[1003];
int main() {
  int result = 0;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[i] = pair<int, int>(a[i], i);
  }
  sort(p + 1, p + 1 + n);
  int x = 0;
  for (int i = n; i > 0; i--) {
    result += p[i].first * x + 1;
    x++;
  }
  cout << result << "\n";
  for (int i = n; i > 0; i--) cout << p[i].second << " ";
  return 0;
}
