#arc130f. [arc130_f]Replace by Average
[arc130_f]Replace by Average
Problem Statement
Given is a sequence of positive integers .
You can do the following operation on this sequence any number of times.
- Choose integers such that and . Replace with .
Find the minimum possible value of after the operations.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5
2 2 5 5 4
Sample Output 1
13
The following operations achieves .
- Do the operation with . The sequence is now .
- Do the operation with . The sequence is now .
- Do the operation with . The sequence is now .
Sample Input 2
5
3 1 4 1 5
Sample Output 2
11
Sample Input 3
3
3 1 3
Sample Output 3
7
Sample Input 4
3
3 5 3
Sample Output 4
9