There are signal pieces in a row. Initially, every piece has displayed value .
Boundary lies between the original pieces and . Its alarm cost is .
Merging consecutive signal pieces creates a bundle. Every bundle consists of a contiguous interval of original pieces and has one displayed value between and .
Choose a boundary that has not been removed and merge the two bundles adjacent to it. Let their displayed values be and .
The chosen boundary is removed and cannot be used again. Perform exactly merges until all pieces form one bundle.
Find the minimum possible total alarm cost.
The input is given in the following format:
For each test case, print the minimum possible total alarm cost on one line.
Removing boundaries in the order makes alarms occur only at boundaries and . The total cost is .
Each case is given in the following format:
| 3 | 69 | No additional constraints. |