#K52007. Subarray with Zero Sum

    ID: 29213 Type: Default 1000ms 256MiB

Subarray with Zero Sum

Subarray with Zero Sum

You are given an array of n integers. Your task is to determine whether there exists a contiguous subarray whose sum is 0.

More formally, given an array \(A = [a_1, a_2, \dots, a_n]\), you need to check if there exist indices \(i\) and \(j\) with \(1 \leq i \leq j \leq n\) such that

\(\sum_{k=i}^{j} a_k = 0\)

Output Yes if such a subarray exists, otherwise output No.

Note: The input will be given via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line of input contains a single integer n indicating the number of elements in the array. The second line contains n space-separated integers representing the elements of the array.

outputFormat

Print a single line containing either Yes if there exists a contiguous subarray with sum 0, or No otherwise.

## sample
5
4 2 -3 1 6
Yes