#K45982. Three Sum Zero

    ID: 27874 Type: Default 1000ms 256MiB

Three Sum Zero

Three Sum Zero

You are given an array of N integers. Your task is to determine whether there exist three distinct elements \( a, b, c \) in the array such that:

\( a + b + c = 0 \)

If such a triplet exists, print YES; otherwise, print NO.

Note: The array may contain duplicate values and negative numbers.

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 array elements.

outputFormat

Output a single line containing YES if there exists a triplet that sums to zero; otherwise, output NO.

## sample
5
-1 0 1 2 -1
YES