| Codeforces Round 1114 (Div. 3) |
|---|
| Finished |
Yousef has a hidden array $$$a$$$ of length $$$n$$$ consisting entirely of strictly positive integers.
An operation was performed exactly once to create an array $$$b$$$:
You are given the shuffled array $$$b$$$. Reconstruct the lexicographically smallest original array $$$a$$$. If it's impossible for any arrangement of $$$b$$$ to produce an array $$$a$$$ of strictly positive integers, output $$$-1$$$.
The first line of input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of the array.
The second line of each test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$) — the elements of the shuffled array $$$b$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output $$$n$$$ strictly positive integers $$$a_1, a_2, \dots, a_n$$$ ($$$a_i \ge 1$$$) — the lexicographically smallest original array $$$a$$$. If it's impossible to create a valid array $$$a$$$, output $$$-1$$$ instead.
8154-5 2 1 16-3 4 2 -1 1 06-2 -2 4 1 0 170 0 -2 3 0 -1 28-1 -1 -1 -1 5 0 0 151000000000 500000000 750000000 100000000 900000000101000000000 -1000000000 500000000 -500000000 1 1 -1 -1 2 -2
5-11 1 3 2 6 31 1 2 6 4 22 1 1 1 1 4 21 1 1 6 5 4 3 2100000000 600000000 1350000000 2250000000 3250000000-1
In the first test case, the only valid array is $$$a = [5]$$$.
In the second test case, there is no valid arrangement of the elements of $$$b$$$ that reconstructs an array $$$a$$$ consisting entirely of strictly positive integers. Therefore, the answer is $$$-1$$$.
In the third test case, one valid arrangement reconstructs the array $$$a=[1,1,3,2,6,3]$$$. The resulting sequence of differences $$$[1, 0, 2, -1, 4, -3]$$$ is a permutation of the given array $$$b$$$, and among all valid reconstructions, this array is lexicographically smallest.
| Name |
|---|


