## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## Dazzling Even-Odd Challenge CodeChef Solution | CodeChef Problem Solution 2022

Dazzler has an interesting task for you.

You will be given an array $A$ of $N$ positive integers such that:

• $N$ is always even.
• Exactly $\frac{N}{2}$ elements in the array are even and $\frac{N}{2}$ elements are odd.

In one operation, you should do the following steps:

• Choose two different indices $i$ and $j$ $\left(1\le i,j\le N\right)$.
• Set ${A}_{i}:={A}_{i}+1$.
• Set ${A}_{j}:={A}_{j}-1$.

You need to apply some finite (possibly zero) number of operations on the array such that:

• The parity of the final element at each index is same as the parity of the initial element at that index. For example, if the ${i}^{th}$ element in the initial array is even, then, the ${i}^{th}$ element in the final array must be even as well.
• All the $\frac{N}{2}$ odd elements in the final array are equal.
• All the $\frac{N}{2}$ even elements in the final array are equal.

Print YES if it is possible to meet all the above conditions after doing some finite (possibly zero) number of operations. Otherwise, print NO.

### Input Format

• First line will contain $T$, number of test cases. Then the test cases follow.
• First line of each test case contains $N$, number of elements in the array $A$. Note that, $N$ is even.
• Second line of each test case contains $N$ space-separated positive integers, the elements of the array.

### Output Format

For each test case, output in a single line, YES if it is possible to meet all the given conditions after doing some finite (possibly zero) number of operations. Otherwise, print NO.

You may print each character of the string in uppercase or lowercase (for example, the strings YeSyEsyes and YES will all be treated as identical).

### Constraints

• $1\le T\le {10}^{4}$
• $2\le N\le 2\cdot {10}^{5}$
• $1\le A\left[i\right]\le {10}^{9}$
• $N\mathrm{%}2=0$
• Sum of $N$ over all test cases does not exceed $2\cdot {10}^{5}$.

### Sample Input 1

4
4
1 1 2 4
4
1 2 5 6
2
1 2
4
1 2 3 4


### Sample Output 1

NO
YES
YES
YES


### Explanation

Test case $1$: It is not possible to satisfy all the given conditions using any number of operations.

Test case $2$: One of the possible sequence of operations is listed below:

• In the first operation, choose $i=2$ and $j=4$. Thus, ${A}_{2}=2+1=3$ and ${A}_{4}=6-1=5$. The array will become $\left[1,3,5,5\right]$.
• In the second operation, choose $i=2$ and $j=4$. Thus, ${A}_{2}=3+1=4$ and ${A}_{4}=5-1=4$. The array will become $\left[1,4,5,4\right]$.
• In the third operation, choose $i=1$ and $j=3$. Thus, ${A}_{1}=1+1=2$ and ${A}_{3}=5-1=4$. The array will become $\left[2,4,4,4\right]$.
• In the fourth operation, choose $i=1$ and $j=3$. Thus, ${A}_{1}=2+1=3$ and ${A}_{3}=4-1=3$. The array will become $\left[3,4,3,4\right]$.

Here, all the odd elements are equal and all the even elements are equal. Also, the parity at each index is preserved.

Test case $3$: The array $\left[1,2\right]$ satisfies all the conditions. Thus, $0$ operations are needed.