#C7053. 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 contiguous subarray whose sum is exactly zero.
Formally, given an array \( a[0], a[1], \dots, a[n-1] \), find if there exists indices \( i \) and \( j \) (with \( 0 \leq i \leq j \leq n-1 \)) such that \( \sum_{k=i}^{j} a[k] = 0 \). If such subarray exists, output "YES"; otherwise, output "NO".
Note: A subarray is defined as a contiguous block of elements in the array.
inputFormat
The first line of input contains a single 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 with the string "YES" if a zero-sum subarray exists, or "NO" otherwise.
## sample5
4 2 -3 1 6
YES
</p>