#P1852B. Imbalanced Arrays

    ID: 9948 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>constructive algorithmsgraphsgreedymathsortingstwo pointers*1800

Imbalanced Arrays

Description

Ntarsis has come up with an array aa of nn non-negative integers.

Call an array bb of nn integers imbalanced if it satisfies the following:

  • nbin-n\le b_i\le n, bi0b_i \ne 0,
  • there are no two indices (i,j)(i, j) (1i,jn1 \le i, j \le n) such that bi+bj=0b_i + b_j = 0,
  • for each 1in1 \leq i \leq n, there are exactly aia_i indices jj (1jn1 \le j \le n) such that bi+bj>0b_i+b_j>0, where ii and jj are not necessarily distinct.

Given the array aa, Ntarsis wants you to construct some imbalanced array. Help him solve this task, or determine it is impossible.

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1051 \le t \le 10^5). The description of the test cases follows.

The first line of each test case has a single integer nn (1n1051 \leq n \leq 10^5).

The next line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (0ain0 \leq a_i \leq n).

It is guaranteed that the sum of nn across all test cases does not exceed 10510^5.

For each test case, output "NO" if there exists no imbalanced array.

Otherwise, output "YES". Then, on the next line, output nn integers b1,b2,,bnb_1, b_2, \ldots, b_n where bi0b_i \neq 0 for all 1in1 \leq i \leq n — an imbalanced array.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1051 \le t \le 10^5). The description of the test cases follows.

The first line of each test case has a single integer nn (1n1051 \leq n \leq 10^5).

The next line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (0ain0 \leq a_i \leq n).

It is guaranteed that the sum of nn across all test cases does not exceed 10510^5.

Output

For each test case, output "NO" if there exists no imbalanced array.

Otherwise, output "YES". Then, on the next line, output nn integers b1,b2,,bnb_1, b_2, \ldots, b_n where bi0b_i \neq 0 for all 1in1 \leq i \leq n — an imbalanced array.

Sample Input 1

5
1
1
4
1 4 3 4
3
0 1 0
4
4 3 2 1
3
1 3 1

Sample Output 1

YES
1 
NO
YES
-3 1 -2 
YES
4 2 -1 -3 
YES
-1 3 -1

Note

For the first test case, b=[1]b = [1] is an imbalanced array. This is because for i=1i = 1, there is exactly one jj (j=1j = 1) where b1+bj>0b_1 + b_j > 0.

For the second test case, it can be shown that there exists no imbalanced array.

For the third test case, a=[0,1,0]a = [0, 1, 0]. The array b=[3,1,2]b = [-3, 1, -2] is an imbalanced array.

  • For i=1i = 1 and i=3i = 3, there exists no index jj such that bi+bj>0b_i + b_j > 0.
  • For i=2i = 2, there is only one index j=2j = 2 such that bi+bj>0b_i + b_j > 0 (b2+b2=1+1=2b_2 + b_2 = 1 + 1 = 2).
Another possible output for the third test case could be b=[2,1,3]b = [-2, 1, -3].