Choose one barrel to maximize the total amount of liquid obtained after an initial fill and additional fill-up steps.
You are given a set of barrels, each with some initial amount of liquid. In one operation, you may choose a barrel and increase its amount according to the problem's rules so that the final result is maximized by focusing resources on the most beneficial barrel.
Your task is to determine the maximum possible amount you can obtain after applying the allowed process exactly as described by the problem.
Input Format
- The first line contains an integer — the number of test cases.
- Each test case consists of:
- one line with an integer ;
- one line with integers describing the barrels.
Output Format
For each test case, print a single integer — the maximum achievable value according to the allowed operation.
Constraints
- across all test cases
- Values fit in 64-bit signed integers
Example 1
Input
2 3 1 2 3 4 10 1 1 1
Output
6 13
Explanation
In each case, the best choice is the barrel that gives the largest resulting value under the stated rule. The sample illustrates that the solution is driven by a greedy comparison of candidates.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.