#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//random No
mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count()); //use by rng()
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPI(i,a,b) for(ll i=a;i>=b;--i)
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define all(a) (a).begin(),(a).end()
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define yes {cout<<'Y'<<'E'<<'S'<<endl; return;}
#define no {cout << 'N' << 'O' << endl; return;}
#define endl "\n"
#define Ka_chow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<": "<<x<<"\n"
#define db2(x, y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define db3(x, y, z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"
#define db4(a, b, c, d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<"\n"
#define db5(a, b, c, d, e) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<"\n"
const int M = 1e9 + 7;
const int N = 1e6 + 7;
#define inf 1000000000000000000
vector<bool> sv(N + 1, true);
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
int prod(const int& a, const int& b)
{
return ((ll)(a)) * b % M;
}
int sum(const int& a, const int& b)
{
int c = a + b;
return c >= M ? c - M : c;
}
int power(int a, int b) {
int ans = 1;
a = a % M;
while (b) {
if (b & 1) ans = (ans * 1LL * a) % M;
a = (a * 1LL * a) % M;
b >>= 1;
}
return ans;
}
void seive() {
sv[0] = false, sv[1] = false;
for (int i = 2; i * i <= N; ++i) {
if (sv[i]) {
for (int j = i * i; j <= N; j += i) sv[j] = 0;
}
}
}
void _print(vector<int> v) {
for (auto &e : v) cout << e << " ";
cout << endl;
}
vi prefixSum(vi v, bool fl) {
vi ans;
int sum = 0;
if (fl) {
for (auto &e : v) {
sum += e;
ans.eb(sum);
}
} else {
REPI(i, v.size() - 1, 0) {
sum += v[i];
ans.eb(sum);
}
}
return ans;
}
//32 r loop logabi 10^9 le & 64 r logabi 10^18 le
void Blue() {
// Think Twice Code Once
int n;
cin >> n;
vi a(n);
REP(i, 0, n) cin >> a[i];
int x = (accumulate(all(a), 0LL)) / n;
for (auto &e : a) e -= x;
// _print(a);
vi v = prefixSum(a, 1);
REP(i, 0, n) if (v[i] < 0) no;
yes;
}
signed main() {
Ka_chow
// seive();
tc(t)
Blue();
}
/*
Only Know You ve Been High When Youre Feeling Low
Only Hate The Road When Youre Missing Home
Only Know You Love Her When You Let Her Go
*/
660A - Co-prime Array | 1692F - 3SUM |
1470A - Strange Birthday Party | 190D - Non-Secret Cypher |
1721B - Deadly Laser | 1721C - Min-Max Array Transformation |
1721A - Image | 1180C - Valeriy and Deque |
557A - Ilya and Diplomas | 1037D - Valid BFS |
1144F - Graph Without Long Directed Paths | 1228A - Distinct Digits |
355B - Vasya and Public Transport | 1230A - Dawid and Bags of Candies |
1530A - Binary Decimal | 1472D - Even-Odd Game |
441C - Valera and Tubes | 1328E - Tree Queries |
265A - Colorful Stones (Simplified Edition) | 296A - Yaroslav and Permutations |
967B - Watering System | 152A - Marks |
1398A - Bad Triangle | 137A - Postcards and photos |
1674D - A-B-C Sort | 334A - Candy Bags |
855A - Tom Riddle's Diary | 1417A - Copy-paste |
1038A - Equality | 1061A - Coins |