Commercial Calculator#4041

Commercial Calculator

2 seconds
64 megabytes
Easy (≈1000)

QISAC has launched a new version of a calculator that charges users for performing arithmetic operations. The cost of each operation is calculated as of the result of that operation, measured in dollars.

You are tasked with calculating the sum of natural numbers using this calculator. Interestingly, the sequence in which you add these numbers can influence the total cost of the calculation, which deviates from the traditional principle that the sum remains unchanged regardless of the order of addends.

For instance, consider adding the numbers , , , and . If you add and first (costing dollars), then add the result to (costing dollars), and finally add (costing dollars), the total cost would be dollars. However, if you first add and (costing dollars), then add and (costing dollars), and finally add the two results together (costing dollars), the total cost would be only dollars.

Your task is to write a program that calculates the minimum cost required to sum these numbers.

Input

The input begins with the number (2 \leq N \leq 100000). This is followed by natural numbers, each not exceeding .

Output

Output the minimum amount of money needed to compute the sum of these numbers, with a precision of at least 10^{-6}.

Examples

Example 1

Loading
Loading