#C1652. Making Array Elements Equal

    ID: 44881 Type: Default 1000ms 256MiB

Making Array Elements Equal

Making Array Elements Equal

You are given several test cases. In each test case, you are given an array of integers. Your task is to determine whether it is possible to make all elements of the array equal by applying the allowed operation.

The only operation allowed is to add an even integer to any element. Since adding an even number does not change the parity (evenness or oddness) of a number, all numbers in the array can only be made equal if they all have the same parity.

Formally, for an array \( a_1, a_2, \dots, a_n \), the answer is "YES" if \( a_i \equiv a_j \pmod{2} \) for all \( i, j \), and "NO" otherwise.

inputFormat

The first line of the input contains an integer \( t \) (\( 1 \le t \le 1000 \)), the number of test cases.
For each test case:

  • The first line contains an integer \( n \) (\( 1 \le n \le 100 \)), the number of elements in the array.
  • The second line contains \( n \) space-separated integers \( a_1, a_2, \dots, a_n \) (\( 0 \le a_i \le 10^6 \)).

outputFormat

For each test case, output a single line containing "YES" if it is possible to make all elements equal; otherwise, output "NO".

## sample
4
3
2 4 6
2
3 3
5
1 2 3 4 5
4
0 0 0 0
YES

YES NO YES

</p>