#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool power_of_two(long long n) { return ((n & (n - 1)) == 0); }
const long long maxn = 10000005;
long long factor[maxn];
void solve() {
  long long n, ans = 1;
  cin >> n;
  vector<long long> a(n + 1);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long cur = a[0];
  long long sub = 0;
  for (long long i = 0; i < n; i++) {
    a[i] += sub;
    cur = min(cur, a[i]);
    cur = max(cur, 0LL);
    a[i] -= cur;
    if (a[i] > 0) {
      sub -= a[i];
      a[i] = 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (a[i] != 0) {
      ans = 0;
      break;
    }
  }
  if (ans)
    cout << "YES";
  else
    cout << "NO";
  cout << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  cin >> t;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
