Ezlulu

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

The Info(1)cup Kingdom hosts the largest cook-off in history. Two of the kingdom’s largest chefs, Lulu and Tanaka both want to prove that they are the best chef in the kingdom. However, the cooking contest is a bit strange: it involves breaking plates. Each contestant receives nn plates of distinct sizes, where each has a certain value. Formally, you receive nn plates, ordered from largest to smallest, and their values v_1,,v_nv\_1, \dots , v\_n. Now, each contestant stacks the plates in any order they want. When a plate is added to the stack, all plates that are smaller than it are broken and removed from the stack. The score of the current plate is calculated as number_of_plates_broken × v_iv\_i, if the value of the plate is v_iv\_i. The total score of a contestant’s performance is the sum of the scores for each of the plates. After hearing about this task, Tanaka says to Lulu: “Beating you will be ez, Lulu”. Help Lulu beat Tanaka by finding the best possible order in which to put the plates on the stack.

입력

The first line of the input contains nn, the number of plates. The next line contains v_1,,v_nv\_1, \dots , v\_n.

출력

The first line of the output contains a single integer which is the maximum score Lulu can make.

The second contains the order in which Lulu should insert the plates in order to achieve this score. For example, if the order is “add the third plate, then the first, then the second”, the output should contain 3 1 2. If there are multiple orders you can print any one of them.

제한

  • 1n200,0001 ≤ n ≤ 200\\,000.
  • 1v_i1,000,000,0001 ≤ v\_i ≤ 1\\,000\\,000\\,000.
  • If only the maximum score is correct, then only 50% of the points for the test are awarded.