#K86272. Subset Sum Zero

    ID: 36828 Type: Default 1000ms 256MiB

Subset Sum Zero

Subset Sum Zero

Given an array of integers, determine if there exists a non-empty subset whose sum is zero. A subset is defined as any selection of elements from the array. You should output YES if such a subset exists, or NO otherwise.

For example, for the array [1, 2, -3, 4], one valid subset is [1, 2, -3] whose sum equals 0. Therefore, the answer is YES.

Note: The input will consist of multiple test cases. For each test case, you will be given the array size followed by the list of integers.

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 number of elements in the array.
  2. The second line contains N space-separated integers.

outputFormat

For each test case, output a single line containing YES if there exists a non-empty subset whose sum is zero, or NO otherwise.

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

YES NO

</p>