P8285 "DAOI R1" Magic

Background

> $ \text{-1,-1,+2} $

Description

Qiaomu came to face the Demon King, and he decided to use magic to defeat the Demon King. Given an integer $n$, meaning there are $n$ magic circles. On each magic circle there is a certain amount of magic power $a_i$. Each time, you may choose three magic circles $i, j, k \;(i, j, k$ are pairwise distinct and $a_i > 0$, $a_j > 0)$, then Qiaomu will decrease the magic power $a_i, a_j$ on the $i$-th and $j$-th magic circles by $1$ respectively, and increase the magic power $a_k$ on the $k$-th magic circle by $2$. We call this one operation. Qiaomu wants to gather all magic power together to achieve the greatest power. He wants to know whether, after some number of operations, it is possible to make the magic power on $n - 1$ magic circles equal to $0$, and make the gathered magic circle's magic power equal to the sum of the magic power of all original magic circles.

Input Format

**This problem contains multiple test cases.** One line contains an integer $T$, the number of test cases. Then for each test case, first input a positive integer $n$, and then input $n$ integers in order. The $i$-th integer represents $a_i$.

Output Format

For each test case output one line. If it can be achieved, output `YES`, otherwise output `NO`.

Explanation/Hint

### Sample Explanation - For the first test case, you can perform the operation twice using $a_1$ and $a_3$ on $a_4$. - For the second test case, it can be proven impossible. ### Constraints - For $5\%$ of the testdata: $1 \le n \le 2$, $0 \le a_i \le 10^3$. - For $20\%$ of the testdata: $1 \le n \le 10$, $0 \le a_i \le 10^3$. - For $100\%$ of the testdata: $1 \le \sum{n} \le 2 \times 10^{6}$, $0 \le a_i \le 10^{9}$. For all testdata, it is guaranteed that $1 \le T \le 100$ and $\sum\limits_{i=1}^{n} a_i \ge 1$. Translated by ChatGPT 5