#arc059a. [arc059_a]Be Together
[arc059_a]Be Together
Problem Statement
Evi has integers . His objective is to have equal integers by transforming some of them.
He may transform each integer at most once. Transforming an integer into another integer costs him dollars. Even if , he has to pay the cost separately for transforming each of them (See Sample 2).
Find the minimum total cost to achieve his objective.
Constraints
Input
The input is given from Standard Input in the following format:
...
Output
Print the minimum total cost to achieve Evi's objective.
Sample Input 1
2
4 8
Sample Output 1
8
Transforming the both into s will cost dollars, which is the minimum.
Sample Input 2
3
1 1 3
Sample Output 2
3
Transforming the all into s will cost dollars. Note that Evi has to pay dollar separately for transforming each of the two s.
Sample Input 3
3
4 2 5
Sample Output 3
5
Leaving the as it is and transforming the and the into s will achieve the total cost of dollars, which is the minimum.
Sample Input 4
4
-100 -100 -100 -100
Sample Output 4
0
Without transforming anything, Evi's objective is already achieved. Thus, the necessary cost is .