//In the name of God
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n, t, a[maxn];
long long ps[maxn];
int main(){
fast_io;
cin >> t;
while(t--){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
ps[i] = ps[i - 1] + a[i];
}
if(ps[n] != 0){
cout << "No\n";
continue;
}
bool ok = 1;
for(int i = 1; i <= n; i++){
if(ps[i] < 0) ok = 0;
}
bool visited_zero = 0;
for(int i = 1; i <= n; i++){
if(ps[i] == 0) visited_zero = 1;
else if(visited_zero) ok = 0;
}
if(ok) cout << "Yes\n";
else cout << "No\n";
}
return 0;
}
1673A - Subtle Substring Subtraction | 1345A - Puzzle Pieces |
711A - Bus to Udayland | 779B - Weird Rounding |
1703D - Double Strings | 1704C - Virus |
63A - Sinking Ship | 1704B - Luke is a Foodie |
298B - Sail | 239A - Two Bags of Potatoes |
1704E - Count Seconds | 682A - Alyona and Numbers |
44A - Indian Summer | 1133C - Balanced Team |
1704A - Two 0-1 Sequences | 1467A - Wizard of Orz |
1714E - Add Modulo 10 | 1714A - Everyone Loves to Sleep |
764A - Taymyr is calling you | 1714B - Remove Prefix |
1264F - Beautiful Fibonacci Problem | 52A - 123-sequence |
1543A - Exciting Bets | 1714D - Color with Occurrences |
215B - Olympic Medal | 1445A - Array Rearrangment |
1351A - A+B (Trial Problem) | 935B - Fafa and the Gates |
1291A - Even But Not Even | 1269A - Equation |