#K11856. Zero Sum Subarray

    ID: 23561 Type: Default 1000ms 256MiB

Zero Sum Subarray

Zero Sum Subarray

Given an array of integers, determine whether there exists a contiguous subarray whose sum is 0. In other words, check if there exists indices i and j such that

\(a_i + a_{i+1} + \cdots + a_j = 0\)

If such a subarray exists, output YES; otherwise, output NO. The array may be empty. For an empty array, the answer is considered NO.

inputFormat

The first line contains an integer n representing the number of elements in the array. The second line contains n space-separated integers.

If n is 0, then there is no second line.

outputFormat

Output a single line with YES if there exists a contiguous subarray with sum 0; otherwise, output NO.

## sample
5
4 2 -3 1 6
YES