ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

2111. Plato

Time limit: 1.0 second
Memory limit: 256 MB
Young and ambitious manager of a transport company Plato got a big order for shipping products from the capital to n cities of the country. Every city is connected with the capital by a double-sided road. There are no other roads in the country. The length of the road between the capital and the city number i equals di kilometers. What a coincidence, that a total weight of the products to ship to the city number i is exactly di tons.
Plato’s truck is loaded only once in the capital. Then Plato starts shipping the products. Of course, he is able to drive only on the road. He may visit the cities in any order, leaving necessary amount of products in each one. There is a tax system, working in the country. To transport m tons of cargo in l kilometers Plato has to pay m × l rubbles. Help Plato calculate the minimum amount of money he has to pay in order to ship all the products to the cities.


The first line contains a single integer n (1 ≤ n ≤ 105)  — the number of cities in the country. The next line contains n integers separated with a space, i-th of which di (1 ≤ di ≤ 104)  — is the length of the road between the city number i and the capital.


In a single line output the minimum amount of money Platon has to pay in order to ship all the products to the cities.


1 2 3
Problem Author: Anna Khanova
Problem Source: University academic school olympiad in informatics 2019