#C10689. Minimum Final Value
Minimum Final Value
Minimum Final Value
You are given a list of n integers. You must perform exactly n - 1 operations to combine these numbers into a single final number. In each operation, you can combine any two numbers and replace them with their sum. It can be proven that the minimum possible final value is simply the sum of all the numbers in the list.
Mathematically, if the sequence is \(a_1, a_2, \ldots, a_n\), then the final value is \(\sum_{i=1}^{n} a_i\).
inputFormat
The input is given in the following format from stdin:
n a1 a2 ... an
Where:
n
is an integer (\(1 \leq n \leq 10^5\)).ai
denotes the integers in the sequence. Each integer will be in the range \(1 \leq a_i \leq 10^9\).
outputFormat
Output a single integer to stdout which is the minimum possible final value, i.e. the sum of all elements in the sequence.
## sample4
1 2 3 4
10
</p>