P15755 [JAG 2025 Summer Camp #1] JAG Box
Description
The JAG Box is an ordinary rectangular box that is currently popular around the world. There are $N$ JAG Boxes. For each $i = 1, 2, \ldots, N$, the $i$-th box has an integer weight $A_i$.
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 $w$ is inserted at the bottom of the existing stack whose total weight is $x$, that box receives load equal to $\left\lfloor \frac{x}{w} \right\rfloor$.
Determine the minimum possible total load over all boxes.
Input Format
The input is given in the following format:
$$\begin{aligned} &N \\ &A_1 \ A_2 \ \ldots \ A_N \end{aligned}$$
- $2 \leq N \leq 200\,000$
- $1 \leq A_i \leq 10^9$ ($1 \leq i \leq N$)
- All input values are integers.
Output Format
Output the answer in a single line.