logo AlgoBeat OnlineJudge
登录 注册

#215812. [JAG 2025 Summer Camp #1] JAG Box

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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:

  • ()
  • All input values are integers.

输出格式

Output the answer in a single line.

样例

样例输入 1

5
3 1 4 1 5

样例输出 1

3