P17721 「FunMusic OI 1D」Love Me or Him / Who Do You Love
Background
Problem source: 【HT-127-Div.3】Walnut CSP-J Mock Contest & 「FunMusic OI R1」

Description
After releasing four albums in a row, David is exhausted and wants to relax by playing cards.
Given $n$ levels of Kings, with levels from $1$ to $n$, where level $1$ is the lowest and level $n$ is the highest, he has $a_i$ Kings of level $i$.
David can perform the following operations any number of times (including $0$ times). Each time, he chooses one of the following three operations:
- Higher kills lower (one kills one): choose an integer $i$ ($1 \le i < n$). If the numbers of level-$i$ and level-$(i+1)$ Kings in his hand are both $\ge 1$, consume $1$ level-$i$ King and $1$ level-$(i+1)$ King.
- Same-level kill (two kill one): choose an integer $i$ ($1 \le i \le n$). If the number of level-$i$ Kings in his hand is $\ge 3$, consume $3$ level-$i$ Kings.
- Lower kills higher (three kill one): choose $i$ ($1 \le i < n$). If the number of level-$i$ Kings in his hand is $\ge 3$ and the number of level-$(i+1)$ Kings is $\ge 1$, consume $3$ level-$i$ Kings and $1$ level-$(i+1)$ King.
His goal is to make the number of Kings of every level become $0$ through a series of operations. Please determine whether such a plan of operations exists.
Input Format
The first line contains an integer $T$, representing the number of test cases.
The next $2T$ lines describe the test cases. For each test case:
- The first line contains an integer $n$.
- The second line contains $n$ integers $a_1, a_2, \cdots, a_n$, representing the numbers of Kings of levels $1, 2, \cdots, n$ in order.
Output Format
For each test case, if all Kings can be cleared, output `YES`; otherwise, output `NO`.
Explanation/Hint
**Sample Explanation**
For the $1$-st sample test case, the following is one plan of operations that meets the requirements:
- The first operation is lower kills higher with $i=1$, consuming $3$ level-$1$ Kings and $1$ level-$2$ King. Now $a=[0, 4, 1]$.
- The second operation is same-level kill with $i=2$, consuming $3$ level-$2$ Kings. Now $a=[0, 1, 1]$.
- The third operation is higher kills lower with $i=2$, consuming one level-$2$ King and one level-$3$ King. Now $a=[0,0,0]$, so the answer is `YES`.
For the $3$-rd sample test case, it can be proved that no plan of operations meets the requirements.
**Constraints**
**This problem uses bundled testing.**
::cute-table{tuack}
| Subtask | $n\le$ | $a_i\le $ | Special property | Score |
| :--------: | :------------: | :-------: | :------: | :--: |
| $1$ | $5$ | $5$ | None | $10$ |
| $2$ | $30$ | $30$ | None | $15$ |
| $3$ | $100$ | $100$ | None | $15$ |
| $4$ | $2\times 10^5$ | $10^9$ | Yes | $5$ |
| $5$ | $2\times 10^5$ | $2$ | None | $15$ |
| $6$ | $2\times 10^5$ | $10^9$ | None | $40$ |
Special property: it is guaranteed that for all $1\le i\le n$, $a_i$ is a multiple of $3$.
For $100\%$ of the testdata, it is guaranteed that $1\le T\le 5$, $1\le n\le 2\times 10^5$, $0\le a_i\le 10^9$.
Translated by QwenWork