| Codeforces Round 1090 (Div. 4) |
|---|
| Finished |
The PMOI wasn't even that awful - word on the street was that the problems were decent, and even (heaven forbid) enjoyable! To Macaque's dismay, however, three unruly participants (Cloud, ChatGBT and Grook) started cheating using their perfect memory of the OEIS. What utter rapscallions! Suddenly, Macaque had to act fast, and devise a problem that these three could not feasibly cheat on. You, demoted from the rank of his companion to his wretched slave, have been enlisted to test.
You are given an array $$$a$$$, initially containing $$$n$$$ non-negative integers.
You perform the following operation exactly $$$n-1$$$ times:
It can be shown that after $$$n-1$$$ operations, exactly one element remains in the array. Your task is to determine the maximum possible value of this final remaining element if you perform the operations optimally.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 3105$$$) — the initial length of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$) — the elements of the array.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3105$$$.
For each test case, output a single integer — the maximum possible value of the final element.
3267 6731 2 31067 667 167 867 267 467 367 567 767 967
031012
In the second test case, the array is $$$[1, 2, 3]$$$. One optimal sequence of operations is:
| Name |
|---|


