#K79147. Zero Sum Subarray

    ID: 35244 Type: Default 1000ms 256MiB

Zero Sum Subarray

Zero Sum Subarray

Given a sequence of n integers, determine whether there exists a contiguous subarray whose sum equals zero. In other words, check if there exists indices \(l\) and \(r\) such that

$$\sum_{i=l}^{r} a_i = 0$$

If such a subarray exists, output YES; otherwise, output NO.

Hint: Use the prefix sum technique. If at any point the prefix sum becomes zero or repeats a previous value, a zero-sum subarray exists.

inputFormat

The first line contains an integer n ( 1 ≤ n), the number of elements in the sequence.

The second line contains n space-separated integers, which are the elements of the array.

outputFormat

Output a single line containing YES if there exists a contiguous subarray whose sum is zero, otherwise output NO.

## sample
5
4 2 -3 1 6
YES