#include <bits/stdc++.h>
using namespace std;
const int dim = 1e6 + 2;
const int mod = 1e9 + 7;
int t, n;
int v[dim], st[dim], dr[dim];
int main() {
  int i;
  cin >> t;
  while (t) {
    --t;
    cin >> n;
    for (i = 1; i <= n; ++i) cin >> v[i];
    if (n < 3) {
      cout << "YES\n";
      continue;
    }
    st[1] = v[1];
    for (i = 2; i <= n; ++i) st[i] = min(v[i], st[i - 1]);
    bool ok = 1;
    for (i = 2; i < n && ok; ++i) {
      if (v[i] > st[i]) {
        int d = v[i] - st[i];
        for (int j = i; j <= n; ++j) {
          v[j] -= d;
          st[j] = min(st[j - 1], v[j]);
          if (v[j] < 0) {
            ok = 0;
            break;
          }
        }
      }
    }
    if (ok)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
