#K73237. Equal Sum Partition

    ID: 33931 Type: Default 1000ms 256MiB

Equal Sum Partition

Equal Sum Partition

You are given a sequence of integers. Your task is to determine whether it is feasible to partition the sequence into two non-empty subsequences such that the sum of the elements in both subsequences is equal.

This problem can be mathematically formulated as follows:

Given a sequence \( a_1, a_2, \dots, a_n \), decide if there exists a subset \( S \subset \{1,2,\dots,n\} \) such that:

[ \sum_{i \in S} a_i = \sum_{j \notin S} a_j, ]

Note: The partition must yield two non-empty subsequences.

Hint: If the total sum of the array is odd, then such a partition is impossible. Otherwise, you may try to find a subset that sums up to half of the total sum using dynamic programming.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
N1
a1 a2 ... aN1
N2
b1 b2 ... bN2
... 
NT
...

Here, the first line contains a single integer T, the number of test cases. For each test case, the first line contains an integer N, the number of elements in the sequence. The next line contains N space-separated integers representing the sequence.

outputFormat

For each test case, print a single line containing either YES if the partition exists or NO otherwise. The output is written to standard output (stdout).

## sample
1
2
2 2
YES

</p>