Problem D

Statement
Copy Copied
D. Retaliationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYousef wants to explode an array $$$a_1, a_2, \dots, a_n$$$. An array gets exploded when all of its elements become equal to zero.In one operation, Yousef can do exactly one of the following:   For every index $$$i$$$ in $$$a$$$, decrease $$$a_i$$$ by $$$i$$$.  For every index $$$i$$$ in $$$a$$$, decrease $$$a_i$$$ by $$$n - i + 1$$$. Your task is to help Yousef determine if it is possible to explode the array using any number of operations.InputThe first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.The first line of each test case contains an integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the size of the array.The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array.It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.OutputFor each test case, print "YES" if Yousef can explode the array, otherwise output "NO".You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.ExampleInput643 6 6 3521 18 15 12 9102 6 10 2 5 5 1 2 4 10710 2 16 12 8 20 4252 101210 2OutputNO
YES
NO
NO
YES
NO
NoteIn the second test case, we can do the following:   Perform $$$1$$$ operation of the first type. The array becomes $$$[20, 16, 12, 8, 4]$$$.  Perform $$$4$$$ operations of the second type. The array becomes $$$[0, 0, 0, 0, 0]$$$. In the first, third, fourth, and sixth test cases, it can be proven that it is impossible to make all elements equal to zero using any number of operations.