atcoder#ARC130F. [ARC130F] Replace by Average
[ARC130F] Replace by Average
Score : points
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.
5
2 2 5 5 4
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 .
5
3 1 4 1 5
11
3
3 1 3
7
3
3 5 3
9