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

University academic school olympiad in informatics 2019

About     Problems     Submit solution     Judge status     Standings
Contest is over

A. 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.

Input

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.

Output

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

Sample

inputoutput
3
1 2 3
36
Problem Author: Anna Khanova
Problem Source: University academic school olympiad in informatics 2019
To submit the solution for this problem go to the Problem set: 2111. Plato