#K76847. Parity Equality

    ID: 34733 Type: Default 1000ms 256MiB

Parity Equality

Parity Equality

You are given an integer T representing the number of test cases. For each test case, you are given an integer N followed by an array A of N integers. Your task is to determine whether it is possible to make all elements equal by performing a sequence of operations.

In each operation, you can increment or decrement an element by 1, but note that such operations do not change the parity (even or odd nature) of a number. In other words, an element will always remain even or odd after any number of operations.

This implies that the array can be made equal if and only if all elements have the same parity. Mathematically, if we denote the elements as \(a_1, a_2, \dots, a_n\), it is possible to equalize them if and only if:

\(a_i \bmod 2 = a_j \bmod 2\) for all \(1 \le i, j \le n\).

Output YES if it is possible, otherwise output NO.

inputFormat

The input is read from standard input (stdin) and follows the format below:

T
N
A1 A2 ... AN
N
A1 A2 ... AN
...

Here, the first line contains the integer T, the number of test cases. For each test case, the first line contains the integer N (the number of elements in the array), followed by a line containing N space-separated integers representing the array elements.

outputFormat

For each test case, output a single line on standard output (stdout) containing YES if all elements can be equalized (i.e., all elements have the same parity), or NO otherwise.

## sample
3
4
2 8 4 6
3
4 5 6
2
7 7
YES

NO YES

</p>