#C7802. Taco Chemical Neutralization
Taco Chemical Neutralization
Taco Chemical Neutralization
You are given n chemical substances with their corresponding volatility values. Your task is to determine whether there exist three distinct substances whose volatilities sum up to zero. In mathematical notation, given an array \(a_1, a_2, \ldots, a_n\), check if there exist indices \(i, j, k\) (all distinct) such that:
\(a_i + a_j + a_k = 0\)
If such a triplet exists, output "YES"; otherwise, output "NO".
inputFormat
The first line of input contains an integer (n) denoting the number of substances. The second line contains (n) space-separated integers representing the volatility values of the substances.
outputFormat
Output a single line containing "YES" if there exists a triplet of distinct substances whose volatility values sum to zero, otherwise output "NO".## sample
5
-1 2 -3 4 1
YES