SECTORS - Equalize the Sectors

no tags 

Digo has a cylindrical box which is vertically partitioned into N contiguous sectors which are open from the top. Each Sectorial Compartment initially contains a fixed number of coins. Now Digo wants to fill each Sectorial Compartment with equal number of coins. But the problem is that, at a time he is only allowed to increment any two adjacent sectors with one coin each. Given an initial arrangement, you need to tell whether such equalization is possible or not.

Every sector i (for all (0 < i < N)) is adjacent to sector (i + 1) and sector N is adjacent to sector 1.

Input

In first line, the number of test cases T.

Each test case consists of a number N, followed by a line containing N space separated integers where ith integer (Mi) denotes the number of coins in ith sectorial compartment of the box (initially), in clockwise order.

Output

For every test case output “YES” for possible and “NO” for which equalization is not possible (Without quotes).

Constraints

1 <= T <= 1000

3 <= N <= 100 (Number of Sectorial Compartments)

1 <= Mi <= 10^9 (Number of coins in each Sectorial Compartment)

Sample Input

2

3

1 2 3

4

1 2 1 2

Sample Output

YES

NO


hide comments
alpha coder: 2014-12-14 22:17:54

something new! nice question !:)


Added by:Surya Kiran
Date:2013-09-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Codeblitz-4