#K72267. Even Sum Pair Verification

    ID: 33716 Type: Default 1000ms 256MiB

Even Sum Pair Verification

Even Sum Pair Verification

You are given an array of integers. Your task is to determine whether there exists a pair of indices i and j with i < j such that the pair (ai, aj) is considered valid according to the following rule:

A pair is valid if either:

  • Both numbers are even, or
  • One number is even and the other is odd.

Note: Even though mathematically the sum of two odd numbers is even, for this problem a pair consisting of two odd numbers is not considered valid.

In other words, if the array contains only odd numbers then the answer is NO. Otherwise, if the array contains at least one even number and at least one other number (either even or odd) so that a pair can be formed, then the answer is YES. Also, a pair of two even numbers is always valid.

The answer for each test case should be printed on a separate line.

The condition we require can be expressed in LaTeX as follows:

\[ \text{Answer} = \begin{cases} YES, & \text{if } E \ge 2 \text{ or } (E \ge 1 \text{ and } O \ge 1), \ NO, & \text{otherwise}, \end{cases} \]

where \(E\) is the number of even elements and \(O\) is the number of odd elements in the array.

inputFormat

The first line of input contains an integer \(T\) denoting the number of test cases. For each test case:

  • The first line contains an integer \(N\), the number of elements in the array.
  • The second line contains \(N\) space-separated integers representing the array elements.

Input is provided via standard input (stdin).

outputFormat

For each test case, output a single line containing YES if a valid pair exists, or NO otherwise. The output should be written to standard output (stdout).

## sample
2
5
1 3 5 7 9
4
2 4 6 8
NO

YES