for _ in range(int(input())):
n=int(input())
l1=list(map(int, input().split()))
for i in range(1, n-1):
l1[i+1]-=l1[i-1]
l1[i]-=2*l1[i-1]
l1[i-1]=0
if l1[i]<0 or l1[i+1]<0:
print('NO')
break
else:
if l1[-1]==0 and l1[-2]==0:
print('YES')
else:
print('NO')
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |