#C10516. Zero-Sum Subarray
Zero-Sum Subarray
Zero-Sum Subarray
You are given an array of integers. Your task is to determine whether there exists a non-empty contiguous subsequence whose sum is 0. In other words, you need to check if there exist indices l and r with 1 \leq l \leq r \leq n such that
\(\sum_{i=l}^{r} a_i = 0\)
If such a subsequence exists, print "Yes"; otherwise, print "No". Note that the empty subsequence is not considered.
inputFormat
The input is given via stdin and has the following format:
- The first line contains an integer n representing the number of elements in the array.
- The second line contains n space-separated integers representing the elements of the array.
outputFormat
Output a single line to stdout containing either "Yes" if there exists at least one contiguous subsequence with a sum of 0, or "No" otherwise.
## sample5
3 -2 1 -1 2
Yes