#include <bits/stdc++.h>
using namespace std;
void swap(long long &a, long long &b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
bool odd(long long n) { return n & 1; }
long long powerof2(long long k) { return (1 << k); }
bool getbit(long long n, long long k) { return n & (1 << (k - 1)); }
void makesetbit(long long &n, long long &k) {
  int t = getbit(n, k);
  if (t)
    return;
  else
    n = n ^ (1 << (k - 1));
}
void makesetunbit(long long &n, long long k) {
  int t = getbit(n, k);
  if (t) n = n ^ (1 << (k - 1));
}
void sieve(set<long long int> &s, vector<bool> &arr) {
  for (int i = 4; i < 10000000001; i += 2) {
    arr[i] = false;
  }
  for (long long int i = 3; i * i < 10000000001; i += 2) {
    if (arr[i] == true) {
      for (long long int j = i * i; j <= 1000000001; j += i) arr[j] = false;
    }
  }
  s.insert(2);
  for (long long int i = 3; i * i < 1000000001; i += 2) {
    if (arr[i]) s.insert(i);
  }
}
bool o(int k, int b) {
  while (k > 0) {
    if (k % 10 == b) return true;
    k /= 10;
  }
  return false;
}
set<int> v;
void squares() {
  for (int i = 1; i < 101; i++) {
    v.insert(i * i);
  }
}
vector<long long> vl;
vector<long long> first(long long *a, long long s, long long n, long long x) {
  static long long index = 0;
  if (a[s] == x) vl.push_back(n - index);
  if (s == 0) return vl;
  index++;
  return first(a, s - 1, n, x);
}
int lengthofstring(string s, long long start) {
  if (s[start] == '\0') return 0;
  return 1 + lengthofstring(s, start + 1);
}
void removeX(char s[]) {
  if (s[0] == '\0') return;
  if (s[0] != 'x')
    removeX(s + 1);
  else {
    long long i;
    for (i = 1; s[i] != '\0'; ++i) {
      s[i - 1] = s[i];
    }
    s[i - 1] = s[i];
    removeX(s);
  }
}
void removedupli(char s[]) {
  if (s[0] == '\0' || s[1] == '\0') return;
  if (s[0] != s[1])
    removedupli(s + 1);
  else {
    long long i;
    for (i = 1; s[i] != '\0'; ++i) {
      s[i - 1] = s[i];
    }
    s[i - 1] = s[i];
    removedupli(s);
  }
}
long long fact(long long a) {
  if (a == 0) return 1;
  return a * fact(a - 1);
}
int divide(long long a, long long b) {
  if (a < b) return 1;
  if (a == b) return 2;
  int ans = divide(a / b, b);
  int an = divide(a, b++);
  return 1 + min(an, ans);
}
long long sumof(long long a) {
  long long sum = 0;
  while (a > 0) {
    sum += a % 10;
    a /= 10;
  }
  return sum;
}
bool compare(string a, string b) { return a.length() < b.length(); }
long long med(vector<long long> arr, long long k) {
  sort(arr.begin(), arr.end(), greater<long long>());
  if (k & 1) return arr[(k - 1) / 2];
  return arr[(k + 1) / 2];
}
bool compo(pair<int, int> arr, pair<int, int> brr) {
  return arr.first > brr.first;
}
string binary(int n) {
  string s = "";
  while (n > 0) {
    s += to_string(n % 2);
    n /= 2;
  }
  return s;
}
int returnf(long long a, int b) {
  int count = 0, m = b;
  while (a > b) {
    b *= m;
    count++;
  }
  return count;
}
bool pairs(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first == p2.first) return p1.second < p2.second;
  return p1.first < p2.first;
}
long long cnt = 0;
long long sum(long long n) {
  long long sums = 0;
  while (n > 0) {
    sums += (n % 10);
    n /= 10;
  }
  return sums;
}
void solve() {
  long long n;
  cin >> n;
  vector<pair<int, int>> arr;
  long long a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr.push_back(make_pair(a, i));
  }
  sort(arr.begin(), arr.end(), compo);
  long long x = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (arr[i].first * x + 1);
    x++;
  }
  cout << sum << '\n';
  for (int i = 0; i < n; i++) cout << arr[i].second + 1 << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
