#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::uint64_t n;
  std::cin >> n;
  std::vector<std::pair<std::uint64_t, std::uint64_t>> vec;
  vec.reserve(n);
  for (int i = 0; i < n; ++i) {
    std::uint64_t value;
    std::cin >> value;
    vec.emplace_back(value, i);
  }
  std::sort(vec.begin(), vec.end(),
            std::greater<std::pair<std::uint64_t, std::uint64_t>>());
  std::uint64_t ans = 0;
  for (int i = 0; i < n; ++i) ans += (vec[i].first * i) + 1;
  std::cout << ans << std::endl;
  for (auto pair : vec) std::cout << pair.second + 1 << ' ';
  return 0;
}
