#K70397. Subarray with Zero Sum

    ID: 33299 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 non-empty contiguous subarray whose sum is equal to 0. Formally, you need to decide 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 subarray exists, print True; otherwise, print False.

inputFormat

The input is read from standard input. The first line contains a single integer N, 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 standard output: True if there exists a contiguous subarray with a sum equal to 0, or False otherwise.

## sample
5
4 2 -3 1 6
True