CF2050B.Transfusion

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Transfusion

You are given an array aa of length nn. In one operation, you can pick an index ii from 22 to n1n-1 inclusive, and do one of the following actions:

  • Decrease ai1a_{i-1} by 11, then increase ai+1a_{i+1} by 11.
  • Decrease ai+1a_{i+1} by 11, then increase ai1a_{i-1} by 11.

After each operation, all the values must be non-negative. Can you make all the elements equal after any number of operations?

Input

First line of input consists of one integer tt (1t1041 \le t \le 10^4)  — the number of test cases.

First line of each test case consists of one integer nn (3n21053 \le n \le 2\cdot 10^5).

Second line of each test case consists of nn integers aia_i (1ai1091 \le a_i \le 10^9).

It is guaranteed that the sum of nn of all test cases doesn't exceed 21052\cdot 10^5.

Output

For each test case, print "YES" without quotation marks if it is possible to make all the elements equal after any number of operations; otherwise, print "NO" without quotation marks.

You can print answers in any register: "yes", "YeS", "nO"  — will also be considered correct.

Samples

8
3
3 2 1
3
1 1 3
4
1 2 5 4
4
1 6 6 1
5
6 2 1 4 2
4
1 4 2 1
5
3 1 2 1 3
3
2 4 2
YES
NO
YES
NO
YES
NO
NO
NO

在线编程 IDE

建议全屏模式获得最佳体验