#K68332. Even Sum Subset

    ID: 32841 Type: Default 1000ms 256MiB

Even Sum Subset

Even Sum Subset

You are given an array of integers. Your task is to determine whether there exists a valid subset of at least two elements whose sum is even. Note that although the sum of two odd numbers is even mathematically, for this problem a subset is considered valid only if it contains at least one even number or it consists of at least two even numbers.

For example:

  • For the array [1, 3, 5], even though 1 + 3 = 4 is even, the subset [1, 3] is not valid because it does not contain any even number. Hence, the answer is NO.
  • For the array [2, 4, 6, 8], there are plenty of even numbers and the answer is YES.
  • For the array [1, 2, 3], the subset [1, 2] includes an even number (2) so the answer is YES.

Your solution should read input from stdin and print the answer to stdout as described below.

inputFormat

The first line contains a single integer n (the number of elements in the array). The second line contains n space-separated integers, representing the elements of the array.

Example:

3
1 3 5

outputFormat

Print a single string: YES if there exists a valid subset as described, or NO otherwise.

Example:

NO
## sample
3
1 3 5
NO