Equal Partition

mediumdynamic programming

Genie has $$$n$$$ boxes of candy with him, he wants to equally distribute these between him and his friend.

The $$$i_{th}$$$ box of candy has $$$a_i$$$ candies inside it. Your task is to determine if it is possible to distribute the candies in such a way that both Genie and his friend end up with the same number of candies.

Note that each box of candy must go to at least one of the $$$2$$$ people.

Input Format:

The first line of each test case contains the integer $$$n(1 \le n \le 200)$$$ — total number of candy boxes.

The second line contains $$$n$$$ integers $$$a_1, a_2... a_n (1 \le a_i \le 100)$$$ – the number of candies in each box.

Output Format:

output "YES" if it is possible to equally partition the candies, and "NO" otherwise.

Examples:

Example 1:

Input:

6
1 2 3 4 5 5

Output:

YES

Example 2:

Input:

4
2 4 6 10

Output:

NO

Code

Loading Editor...