#C3539. Zero Sum Subarray Detection

    ID: 46977 Type: Default 1000ms 256MiB

Zero Sum Subarray Detection

Zero Sum Subarray Detection

Given a list of integer temperature readings representing daily changes, determine if there exists any non-empty subarray whose sum equals zero. Formally, given an array \(a_1, a_2, \dots, a_n\), check whether there exist indices \(i\) and \(j\) with \(1 \le i \le j \le n\) such that \(\sum_{k=i}^{j} a_k = 0\). If such a subarray exists, output "YES"; otherwise, output "NO".

inputFormat

The input is read from standard input (stdin). The first line contains an integer \(T\) denoting the number of test cases. Each test case consists of two lines: the first line contains an integer \(n\) (the number of days), and the second line contains \(n\) space-separated integers representing the temperature readings.

outputFormat

For each test case, print a single line to standard output (stdout) containing either "YES" if there is at least one subarray with a sum of zero, or "NO" if there is none.

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

YES NO

</p>