#P15755. [JAG 2025 Summer Camp #1] JAG Box
[JAG 2025 Summer Camp #1] JAG Box
题目描述
The JAG Box is an ordinary rectangular box that is currently popular around the world. There are JAG Boxes. For each , the -th box has an integer weight .
You will build a vertical stack by repeatedly choosing one remaining box and inserting it at the very bottom of the current stack. When a box of weight is inserted at the bottom of the existing stack whose total weight is , that box receives load equal to .
Determine the minimum possible total load over all boxes.
输入格式
The input is given in the following format:
$$\begin{aligned} &N \\ &A_1 \ A_2 \ \ldots \ A_N \end{aligned} $$- ()
- All input values are integers.
输出格式
Output the answer in a single line.
5
3 1 4 1 5
3