https://codeforces.com/problemset/problem/1941/B
#include<bits/stdc++.h>
using namespace std;
const int N=1e5*3+10;
int a[N],n,m;
int main(void)
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>m;
for(int j=1;j<=m;j++) cin>>a[j];
int flag=1;
for(int j=1;j+2<=m;j++)
{
if(a[j]>0) a[j+1]=a[j+1]-a[j]*2,a[j+2]-=a[j],a[j]=0;
}
for(int j=1;j<=m;j++) if(a[j]) flag=0;
if(flag) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}