## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] 3SUM Closure Codeforces Solution | Codeforces Problem Solution 2022

C. 3SUM Closure
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array $a$ of length $n$. The array is called 3SUM-closed if for all distinct indices $i$$j$$k$, the sum ${a}_{i}+{a}_{j}+{a}_{k}$ is an element of the array. More formally, $a$ is 3SUM-closed if for all integers $1\le i, there exists some integer $1\le l\le n$ such that ${a}_{i}+{a}_{j}+{a}_{k}={a}_{l}$.

Determine if $a$ is 3SUM-closed.

Input

The first line contains an integer $t$ ($1\le t\le 1000$) — the number of test cases.

The first line of each test case contains an integer $n$ ($3\le n\le 2\cdot {10}^{5}$) — the length of the array.

Solution Click Below:-  👉
👇👇👇👇👇

The second line of each test case contains $n$ integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($-{10}^{9}\le {a}_{i}\le {10}^{9}$) — the elements of the array.

It is guaranteed that the sum of $n$ across all test cases does not exceed $2\cdot {10}^{5}$.

Output

For each test case, output "YES" (without quotes) if $a$ is 3SUM-closed and "NO" (without quotes)

otherwise.

You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).