#K93227. Taco: Equal Sum Partition

    ID: 38373 Type: Default 1000ms 256MiB

Taco: Equal Sum Partition

Taco: Equal Sum Partition

Hemose has an array of n integers and wonders if he can split the array into two contiguous subarrays with equal sum after using a special operation any number of times (possibly 0). The operation is defined as follows:

  • Choose an index i such that \(1 \le i \le n-1\) and split the array into a left subarray and a right subarray.
  • Then, select indices k and m (with \(1 \le k \le |left|\) and \(1 \le m \le |right|\)) and swap left[k] with right[m].

Your task is to determine whether it is possible to perform a finite number of such operations so that the two resulting contiguous subarrays have equal sum. If it is possible, output YES; otherwise, output NO.

inputFormat

The first line contains an integer t denoting the number of test cases. Each test case consists of two lines:

  1. The first line contains an integer n, the size of the array.
  2. The second line contains n space-separated integers representing the array elements.

outputFormat

For each test case, output a single line containing YES if it is possible to split the array into two contiguous subarrays with equal sum after applying the allowed operations, and NO otherwise.

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

YES NO

</p>